| Conditions | 9 | 
| Paths | 9 | 
| Total Lines | 57 | 
| Code Lines | 32 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 5 | ||
| 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  | 
            ||
| 58 | public static function parse($definition): array  | 
            ||
| 59 |     { | 
            ||
| 60 |         if (!is_array($definition)) { | 
            ||
| 61 | return [$definition, []];  | 
            ||
| 62 | }  | 
            ||
| 63 | |||
| 64 | // Dedicated definition  | 
            ||
| 65 |         if (isset($definition[self::DEFINITION_META])) { | 
            ||
| 66 | $newDefinition = $definition[self::DEFINITION_META];  | 
            ||
| 67 | unset($definition[self::DEFINITION_META]);  | 
            ||
| 68 | |||
| 69 | return [$newDefinition, $definition];  | 
            ||
| 70 | }  | 
            ||
| 71 | |||
| 72 | // Callable definition  | 
            ||
| 73 |         if (is_callable($definition, true)) { | 
            ||
| 74 | return [$definition, []];  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | // Array definition  | 
            ||
| 78 | $meta = [];  | 
            ||
| 79 | $class = null;  | 
            ||
| 80 | $constructorArguments = [];  | 
            ||
| 81 | $methodsAndProperties = [];  | 
            ||
| 82 |         foreach ($definition as $key => $value) { | 
            ||
| 83 | // Class  | 
            ||
| 84 |             if ($key === ArrayDefinition::CLASS_NAME) { | 
            ||
| 85 | $class = $value;  | 
            ||
| 86 | continue;  | 
            ||
| 87 | }  | 
            ||
| 88 | |||
| 89 | // Constructor arguments  | 
            ||
| 90 |             if ($key === ArrayDefinition::CONSTRUCTOR) { | 
            ||
| 91 | $constructorArguments = $value;  | 
            ||
| 92 | continue;  | 
            ||
| 93 | }  | 
            ||
| 94 | |||
| 95 | // Methods and properties  | 
            ||
| 96 |             if (count($methodArray = explode('()', $key)) === 2) { | 
            ||
| 97 | $methodsAndProperties[$key] = [ArrayDefinition::TYPE_METHOD, $methodArray[0], $value];  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 98 | continue;  | 
            ||
| 99 | }  | 
            ||
| 100 |             if (count($propertyArray = explode('$', $key)) === 2) { | 
            ||
| 101 | $methodsAndProperties[$key] = [ArrayDefinition::TYPE_PROPERTY, $propertyArray[1], $value];  | 
            ||
| 102 | continue;  | 
            ||
| 103 | }  | 
            ||
| 104 | |||
| 105 | $meta[$key] = $value;  | 
            ||
| 106 | }  | 
            ||
| 107 | return [  | 
            ||
| 108 | [  | 
            ||
| 109 | $class,  | 
            ||
| 110 | $constructorArguments,  | 
            ||
| 111 | $methodsAndProperties,  | 
            ||
| 112 | self::IS_PREPARED_ARRAY_DEFINITION_DATA => true,  | 
            ||
| 113 | ],  | 
            ||
| 114 | $meta,  | 
            ||
| 115 | ];  | 
            ||
| 118 |