src/Analysis/Checker/Complexity/ClassComplexityChecker.php 1 location
|
@@ 10-36 (lines=27) @@
|
| 7 |
|
use Inspector\Analysis\Exception\ClassTooComplexException; |
| 8 |
|
use Inspector\Analysis\Checker\Complexity\AbstractComplexityChecker as ComplexityChecker; |
| 9 |
|
|
| 10 |
|
class ClassComplexityChecker extends ComplexityChecker |
| 11 |
|
{ |
| 12 |
|
|
| 13 |
|
/** |
| 14 |
|
* Checks to make sure the class is not that complex |
| 15 |
|
* |
| 16 |
|
* @param Node $node |
| 17 |
|
* @throws ClassTooComplexException |
| 18 |
|
*/ |
| 19 |
|
public function check(Node $node) |
| 20 |
|
{ |
| 21 |
|
if (($node instanceof Class_) && $this->isComplex($node)) { |
| 22 |
|
throw (new ClassTooComplexException())->setNode($node); |
| 23 |
|
} |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
/** |
| 27 |
|
* @param array $params |
| 28 |
|
* @return $this |
| 29 |
|
*/ |
| 30 |
|
public function setParameters(array $params) |
| 31 |
|
{ |
| 32 |
|
$this->setThreshold($params['complexity_threshold']['class']); |
| 33 |
|
|
| 34 |
|
return $this; |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|
src/Analysis/Checker/Complexity/FunctionComplexityChecker.php 1 location
|
@@ 11-37 (lines=27) @@
|
| 8 |
|
use Inspector\Analysis\Checker\Complexity\AbstractComplexityChecker as ComplexityChecker; |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
class FunctionComplexityChecker extends ComplexityChecker |
| 12 |
|
{ |
| 13 |
|
|
| 14 |
|
/** |
| 15 |
|
* Checks to make sure the function is not that complex |
| 16 |
|
* |
| 17 |
|
* @param Node $node |
| 18 |
|
* @throws FunctionTooComplexException |
| 19 |
|
*/ |
| 20 |
|
public function check(Node $node) |
| 21 |
|
{ |
| 22 |
|
if (($node instanceof Function_) && $this->isComplex($node)) { |
| 23 |
|
throw (new FunctionTooComplexException())->setNode($node); |
| 24 |
|
} |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
/** |
| 28 |
|
* @param array $params |
| 29 |
|
* @return $this |
| 30 |
|
*/ |
| 31 |
|
public function setParameters(array $params) |
| 32 |
|
{ |
| 33 |
|
$this->setThreshold($params['complexity_threshold']['function']); |
| 34 |
|
|
| 35 |
|
return $this; |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|
src/Analysis/Checker/Complexity/MethodComplexityChecker.php 1 location
|
@@ 10-36 (lines=27) @@
|
| 7 |
|
use Inspector\Analysis\Exception\MethodTooComplexException; |
| 8 |
|
use Inspector\Analysis\Checker\Complexity\AbstractComplexityChecker as ComplexityChecker; |
| 9 |
|
|
| 10 |
|
class MethodComplexityChecker extends ComplexityChecker |
| 11 |
|
{ |
| 12 |
|
|
| 13 |
|
/** |
| 14 |
|
* Checks to make sure the class method is not that complex |
| 15 |
|
* |
| 16 |
|
* @param Node $node |
| 17 |
|
* @throws MethodTooComplexException |
| 18 |
|
*/ |
| 19 |
|
public function check(Node $node) |
| 20 |
|
{ |
| 21 |
|
if (($node instanceof ClassMethod) && $this->isComplex($node)) { |
| 22 |
|
throw (new MethodTooComplexException)->setNode($node); |
| 23 |
|
} |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
/** |
| 27 |
|
* @param array $params |
| 28 |
|
* @return $this |
| 29 |
|
*/ |
| 30 |
|
public function setParameters(array $params) |
| 31 |
|
{ |
| 32 |
|
$this->setThreshold($params['complexity_threshold']['method']); |
| 33 |
|
|
| 34 |
|
return $this; |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|