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