| Conditions | 10 | 
| Paths | 54 | 
| Total Lines | 37 | 
| Code Lines | 21 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| 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  | 
            ||
| 36 | private function setIndexed(string $entityType, string $path, $value): void  | 
            ||
| 37 |     { | 
            ||
| 38 |         [$path, $index] = explode('.', $path, 2); | 
            ||
| 39 | |||
| 40 | $field = null;  | 
            ||
| 41 |         if (strpos($index, '.') > 0) { | 
            ||
| 42 |             [$index, $field] = explode('.', $index, 2); | 
            ||
| 43 | }  | 
            ||
| 44 | |||
| 45 | $target = $index;  | 
            ||
| 46 |         if (!is_numeric($index)) { | 
            ||
| 47 |             if (\is_array($value)) { | 
            ||
| 48 | $value['type'] = $index;  | 
            ||
| 49 | }  | 
            ||
| 50 | $index = null;  | 
            ||
| 51 |             if (isset($this->data[$entityType][$path])) { | 
            ||
| 52 |                 foreach ((array)$this->data[$entityType][$path] as $nodeIndex => $node) { | 
            ||
| 53 |                     if (isset($node['type']) && $node['type'] === $target) { | 
            ||
| 54 | $index = $nodeIndex;  | 
            ||
| 55 | break;  | 
            ||
| 56 | }  | 
            ||
| 57 | }  | 
            ||
| 58 | }  | 
            ||
| 59 | }  | 
            ||
| 60 | |||
| 61 | // No index found, new entry  | 
            ||
| 62 |         if ($index === null) { | 
            ||
| 63 | $this->addNewEntry($entityType, $path, $field, $target, $value);  | 
            ||
| 64 | return;  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 | // Use found index  | 
            ||
| 68 |         if ($field === null) { | 
            ||
| 69 | $this->data[$entityType][$path][$index] = $value;  | 
            ||
| 70 | return;  | 
            ||
| 71 | }  | 
            ||
| 72 | $this->data[$entityType][$path][$index][$field] = $value;  | 
            ||
| 73 | }  | 
            ||
| 93 |