codeformunich/Muenchen-Transparent

View on GitHub
protected/RISParser/ReferentInnenParser.php

Summary

Maintainability
A
1 hr
Test Coverage

Method createIfNotExistsReferentIn has 33 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    public function createIfNotExistsReferentIn(ReferatData $data, Referat $referat): void
    {
        /** @var StadtraetIn $str */
        $str = StadtraetIn::model()->findByPk($data->referentInId);
        if ($str) {
Severity: Minor
Found in protected/RISParser/ReferentInnenParser.php - About 1 hr to fix

    Avoid using count() function in for loops.
    Open

            for ($i = 0; $i < count($parts); $i++) {
                $parsed = ReferatData::parseFromHtml($parts[$i]);
                $referat = $this->createIfNotExistsReferat($parsed);
                $this->createIfNotExistsReferentIn($parsed, $referat);
            }

    CountInLoopExpression

    Since: 2.7.0

    Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

    Example

    class Foo {
    
      public function bar()
      {
        $array = array();
    
        for ($i = 0; count($array); $i++) {
          // ...
        }
      }
    }

    Source https://phpmd.org/rules/design.html#countinloopexpression

    There are no issues that match your filters.

    Category
    Status