codeformunich/Muenchen-Transparent

View on GitHub
protected/commands/Delete_DocumentsCommand.php

Summary

Maintainability
A
0 mins
Test Coverage

The method run() contains an exit expression.
Open

        if (count($args) == 0) die("./yii delete_documents [Dokument-ID|alle]\n");

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

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

Avoid using count() function in for loops.
Open

            for ($i = 0; $i < count($data); $i++) {
                if (($i % 100) == 0) echo $i . " / " . count($data) . "\n";
                $parser->checkAndDeleteDocument($data[$i]);
            }

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