| Conditions | 10 |
| Paths | 32 |
| Total Lines | 55 |
| Code Lines | 32 |
| 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 |
||
| 94 | public function queueRelations(CC $parentStore, $parentEntity, Node $parentNode, array $parentData): CC |
||
| 95 | { |
||
| 96 | $state = $parentNode->getState(); |
||
| 97 | $sequence = new ContextSequence(); |
||
| 98 | |||
| 99 | // queue all "left" graph branches |
||
| 100 | foreach ($this->dependencies as $name => $relation) { |
||
| 101 | if (!$relation->isCascade() || $parentNode->getState()->visited($name)) { |
||
| 102 | continue; |
||
| 103 | } |
||
| 104 | $state->markVisited($name); |
||
| 105 | |||
| 106 | $command = $this->queueRelation( |
||
| 107 | $parentStore, |
||
| 108 | $parentEntity, |
||
| 109 | $parentNode, |
||
| 110 | $relation, |
||
| 111 | $relation->extract($parentData[$name] ?? null), |
||
| 112 | $parentNode->getRelation($name) |
||
| 113 | ); |
||
| 114 | |||
| 115 | if ($command !== null) { |
||
| 116 | $sequence->addCommand($command); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | // queue target entity |
||
| 121 | $sequence->addPrimary($parentStore); |
||
| 122 | |||
| 123 | // queue all "right" graph branches |
||
| 124 | foreach ($this->relations as $name => $relation) { |
||
| 125 | if (!$relation->isCascade() || $parentNode->getState()->visited($name)) { |
||
| 126 | continue; |
||
| 127 | } |
||
| 128 | $state->markVisited($name); |
||
| 129 | |||
| 130 | $command = $this->queueRelation( |
||
| 131 | $parentStore, |
||
| 132 | $parentEntity, |
||
| 133 | $parentNode, |
||
| 134 | $relation, |
||
| 135 | $relation->extract($parentData[$name] ?? null), |
||
| 136 | $parentNode->getRelation($name) |
||
| 137 | ); |
||
| 138 | |||
| 139 | if ($command !== null) { |
||
| 140 | $sequence->addCommand($command); |
||
| 141 | } |
||
| 142 | } |
||
| 143 | |||
| 144 | if (count($sequence) === 1) { |
||
| 145 | return current($sequence->getCommands()); |
||
| 146 | } |
||
| 147 | |||
| 148 | return $sequence; |
||
| 149 | } |
||
| 188 | } |