| Conditions | 12 |
| Paths | 75 |
| Total Lines | 64 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 56 | public function format() |
||
| 57 | { |
||
| 58 | $output = '@startuml' . PHP_EOL; |
||
| 59 | |||
| 60 | foreach ($this->components as $component) { |
||
| 61 | $output .= "namespace {$component->getName()} {" . PHP_EOL; |
||
| 62 | |||
| 63 | foreach ($this->graph->getClasses() as $class) { |
||
| 64 | if ($component->isBelongedTo($class->getId())) { |
||
| 65 | if (!$this->isExcludeClass($class->getId())) { |
||
| 66 | $output .= "class {$class->getId()} {" . PHP_EOL; |
||
| 67 | $output .= '}' . PHP_EOL; |
||
| 68 | } |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | $output .= '}' . PHP_EOL; |
||
| 73 | } |
||
| 74 | |||
| 75 | foreach ($this->graph->getClasses() as $class) { |
||
| 76 | if ($this->isExcludeClass($class->getId())) { |
||
| 77 | continue; |
||
| 78 | } |
||
| 79 | |||
| 80 | foreach ($this->components as $component) { |
||
| 81 | if ($component->isBelongedTo($class->getId())) { |
||
| 82 | continue 2; |
||
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | $output .= "class {$class->getId()} {" . PHP_EOL; |
||
| 87 | $output .= '}' . PHP_EOL; |
||
| 88 | } |
||
| 89 | |||
| 90 | // foreach ($this->groupedClasses as $componentName => $classes) { |
||
| 91 | // if ($componentName !== '') { |
||
| 92 | // $output .= "namespace {$componentName} {" . PHP_EOL; |
||
| 93 | // } |
||
| 94 | // |
||
| 95 | // foreach ($classes as $class) { |
||
| 96 | // if (!$this->isExcludeClass($class)) { |
||
| 97 | // $output .= "class {$class} {" . PHP_EOL; |
||
| 98 | // $output .= '}' . PHP_EOL; |
||
| 99 | // } |
||
| 100 | // } |
||
| 101 | // |
||
| 102 | // if ($componentName !== '') { |
||
| 103 | // $output .= '}' . PHP_EOL; |
||
| 104 | // } |
||
| 105 | // } |
||
| 106 | |||
| 107 | foreach ($this->graph->getDependencyArrows() as $edge) { |
||
| 108 | $depender = $edge->getVertexStart(); |
||
| 109 | $dependee = $edge->getVertexEnd(); |
||
| 110 | |||
| 111 | if ($this->isExcludeClass($depender->getId()) || $this->isExcludeClass($dependee->getId())) { |
||
| 112 | continue; |
||
| 113 | } |
||
| 114 | $output .= "{$this->searchGroupedClasses($depender->getId())} --> {$this->searchGroupedClasses($dependee->getId())}" . PHP_EOL; |
||
| 115 | } |
||
| 116 | |||
| 117 | $output .= '@enduml'; |
||
| 118 | |||
| 119 | return $output; |
||
| 120 | } |
||
| 172 |