| Conditions | 11 |
| Paths | 4 |
| Total Lines | 47 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 48 | public function isSatisfyBy(DependencyGraph $graph): VerifyDependencyResponse |
||
| 49 | { |
||
| 50 | $response = new VerifyDependencyResponse($this->getRuleName()); |
||
| 51 | |||
| 52 | foreach ($graph->getDependencyArrows() as $dependencyArrow) { |
||
| 53 | foreach ($dependencyArrow->getDependencies() as $dependency) { |
||
| 54 | /** @var DependencyGraph\FullyQualifiedStructuralElementName\Base $dependerFQSEN */ |
||
| 55 | $dependerFQSEN = $dependency[0]; |
||
| 56 | /** @var DependencyGraph\FullyQualifiedStructuralElementName\Base $dependeeFQSEN */ |
||
| 57 | $dependeeFQSEN = $dependency[1]; |
||
| 58 | // $depender = $dependencyArrow->getDependerClass(); |
||
| 59 | // $dependee = $dependencyArrow->getDependeeClass(); |
||
| 60 | |||
| 61 | // TODO: add exclude rule |
||
| 62 | $dependerComponent = $this->getComponent($dependerFQSEN); |
||
| 63 | $dependeeComponent = $this->getComponent($dependeeFQSEN); |
||
| 64 | if (is_null($dependerComponent) || is_null($dependeeComponent) || $dependerComponent === $dependeeComponent) { |
||
| 65 | continue; |
||
| 66 | } |
||
| 67 | |||
| 68 | foreach ($this->components as $component) { |
||
| 69 | if ($component->isBelongedTo($dependeeFQSEN->toString())) { |
||
| 70 | if (!$component->verifyDepender($dependerFQSEN, $dependeeFQSEN)) { |
||
| 71 | $response->addRuleViolation( |
||
| 72 | $dependerComponent->getName(), |
||
| 73 | $dependerFQSEN->toString(), |
||
| 74 | $dependeeComponent->getName(), |
||
| 75 | $dependeeFQSEN->toString() |
||
| 76 | ); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | if ($component->isBelongedTo($dependerFQSEN->toString())) { |
||
| 81 | if (!$component->verifyDependee($dependeeFQSEN->toString())) { |
||
| 82 | $response->addRuleViolation( |
||
| 83 | $dependerComponent->getName(), |
||
| 84 | $dependerFQSEN->toString(), |
||
| 85 | $dependeeComponent->getName(), |
||
| 86 | $dependeeFQSEN->toString() |
||
| 87 | ); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | return $response; |
||
| 95 | } |
||
| 128 |