protected/RISParser/ReferentInnenParser.php
Method createIfNotExistsReferentIn
has 33 lines of code (exceeds 30 allowed). Consider refactoring. Open
Open
public function createIfNotExistsReferentIn(ReferatData $data, Referat $referat): void
{
/** @var StadtraetIn $str */
$str = StadtraetIn::model()->findByPk($data->referentInId);
if ($str) {
Avoid using count() function in for loops. Open
Open
for ($i = 0; $i < count($parts); $i++) {
$parsed = ReferatData::parseFromHtml($parts[$i]);
$referat = $this->createIfNotExistsReferat($parsed);
$this->createIfNotExistsReferentIn($parsed, $referat);
}
- Read upRead up
- Exclude checks
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++) {
// ...
}
}
}