| Conditions | 10 |
| Paths | 27 |
| Total Lines | 88 |
| Code Lines | 18 |
| 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 |
||
| 61 | public function format() |
||
| 62 | { |
||
| 63 | $output = '@startuml' . PHP_EOL; |
||
| 64 | |||
| 65 | foreach ($this->groupedClasses as $componentName => $classNames) { |
||
| 66 | $component = $this->getComponentByName($componentName); |
||
| 67 | |||
| 68 | if (!is_null($component) && $component->getAttribute('namespace')) { |
||
| 69 | $output .= "namespace {$component->getName()} {" . PHP_EOL; |
||
| 70 | } |
||
| 71 | |||
| 72 | foreach ($classNames as $className) { |
||
| 73 | $output .= "class {$className} {" . PHP_EOL; |
||
| 74 | $output .= '}' . PHP_EOL; |
||
| 75 | } |
||
| 76 | |||
| 77 | if (!is_null($component) && $component->getAttribute('namespace')) { |
||
| 78 | $output .= '}' . PHP_EOL; |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | // foreach ($this->components as $component) { |
||
| 83 | // if ($component->getAttribute('namespace')) { |
||
| 84 | // $output .= "namespace {$component->getName()} {" . PHP_EOL; |
||
| 85 | // } |
||
| 86 | // |
||
| 87 | // foreach ($this->graph->getClasses() as $class) { |
||
| 88 | // if ($component->isBelongedTo($class->getId())) { |
||
| 89 | // if (!$this->isExcludeClass($class->getId())) { |
||
| 90 | // $output .= "class {$class->getId()} {" . PHP_EOL; |
||
| 91 | // $output .= '}' . PHP_EOL; |
||
| 92 | // } |
||
| 93 | // } |
||
| 94 | // } |
||
| 95 | // |
||
| 96 | // if ($component->getAttribute('namespace')) { |
||
| 97 | // $output .= '}' . PHP_EOL; |
||
| 98 | // } |
||
| 99 | // } |
||
| 100 | // |
||
| 101 | // foreach ($this->graph->getClasses() as $class) { |
||
| 102 | // if ($this->isExcludeClass($class->getId())) { |
||
| 103 | // continue; |
||
| 104 | // } |
||
| 105 | // |
||
| 106 | // foreach ($this->components as $component) { |
||
| 107 | // if ($component->getAttribute('namespace') && $component->isBelongedTo($class->getId())) { |
||
| 108 | // continue 2; |
||
| 109 | // } |
||
| 110 | // } |
||
| 111 | // |
||
| 112 | // $output .= "class {$class->getId()} {" . PHP_EOL; |
||
| 113 | // $output .= '}' . PHP_EOL; |
||
| 114 | // } |
||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | |||
| 119 | // foreach ($this->groupedClasses as $componentName => $classes) { |
||
| 120 | // if ($componentName !== '') { |
||
| 121 | // $output .= "namespace {$componentName} {" . PHP_EOL; |
||
| 122 | // } |
||
| 123 | // |
||
| 124 | // foreach ($classes as $class) { |
||
| 125 | // if (!$this->isExcludeClass($class)) { |
||
| 126 | // $output .= "class {$class} {" . PHP_EOL; |
||
| 127 | // $output .= '}' . PHP_EOL; |
||
| 128 | // } |
||
| 129 | // } |
||
| 130 | // |
||
| 131 | // if ($componentName !== '') { |
||
| 132 | // $output .= '}' . PHP_EOL; |
||
| 133 | // } |
||
| 134 | // } |
||
| 135 | |||
| 136 | foreach ($this->graph->getDependencyArrows() as $edge) { |
||
| 137 | $depender = $edge->getVertexStart(); |
||
| 138 | $dependee = $edge->getVertexEnd(); |
||
| 139 | |||
| 140 | if ($this->isExcludeClass($depender->getId()) || $this->isExcludeClass($dependee->getId())) { |
||
| 141 | continue; |
||
| 142 | } |
||
| 143 | $output .= "{$this->searchGroupedClasses($depender->getId())} --> {$this->searchGroupedClasses($dependee->getId())}" . PHP_EOL; |
||
| 144 | } |
||
| 145 | |||
| 146 | $output .= '@enduml'; |
||
| 147 | |||
| 148 | return $output; |
||
| 149 | } |
||
| 238 |