| Conditions | 22 | 
| Paths | 37 | 
| Total Lines | 55 | 
| Code Lines | 42 | 
| Lines | 0 | 
| Ratio | 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  | 
            ||
| 24 | public function guessType($class, $property, ModelManagerInterface $modelManager)  | 
            ||
| 25 |     { | 
            ||
| 26 |         if (!$ret = $this->getParentMetadataForProperty($class, $property, $modelManager)) { | 
            ||
| 27 |             return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); | 
            ||
| 28 | }  | 
            ||
| 29 | |||
| 30 | list($metadata, $propertyName, $parentAssociationMappings) = $ret;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 31 | |||
| 32 |         if ($metadata->hasAssociation($propertyName)) { | 
            ||
| 33 | $mapping = $metadata->getAssociationMapping($propertyName);  | 
            ||
| 34 | |||
| 35 |             switch ($mapping['type']) { | 
            ||
| 36 | case ClassMetadataInfo::ONE_TO_MANY:  | 
            ||
| 37 |                     return new TypeGuess('orm_one_to_many', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 38 | |||
| 39 | case ClassMetadataInfo::MANY_TO_MANY:  | 
            ||
| 40 |                     return new TypeGuess('orm_many_to_many', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 41 | |||
| 42 | case ClassMetadataInfo::MANY_TO_ONE:  | 
            ||
| 43 |                     return new TypeGuess('orm_many_to_one', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 44 | |||
| 45 | case ClassMetadataInfo::ONE_TO_ONE:  | 
            ||
| 46 |                     return new TypeGuess('orm_one_to_one', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 47 | }  | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 |         switch ($metadata->getTypeOfField($propertyName)) { | 
            ||
| 51 | case 'array':  | 
            ||
| 52 | case 'json':  | 
            ||
| 53 |                 return new TypeGuess('array', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 54 | case 'boolean':  | 
            ||
| 55 |                 return new TypeGuess('boolean', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 56 | case 'datetime':  | 
            ||
| 57 | case 'vardatetime':  | 
            ||
| 58 | case 'datetimetz':  | 
            ||
| 59 |                 return new TypeGuess('datetime', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 60 | case 'date':  | 
            ||
| 61 |                 return new TypeGuess('date', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 62 | case 'decimal':  | 
            ||
| 63 | case 'float':  | 
            ||
| 64 |                 return new TypeGuess('number', array(), Guess::MEDIUM_CONFIDENCE); | 
            ||
| 65 | case 'integer':  | 
            ||
| 66 | case 'bigint':  | 
            ||
| 67 | case 'smallint':  | 
            ||
| 68 |                 return new TypeGuess('integer', array(), Guess::MEDIUM_CONFIDENCE); | 
            ||
| 69 | case 'string':  | 
            ||
| 70 |                 return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE); | 
            ||
| 71 | case 'text':  | 
            ||
| 72 |                 return new TypeGuess('textarea', array(), Guess::MEDIUM_CONFIDENCE); | 
            ||
| 73 | case 'time':  | 
            ||
| 74 |                 return new TypeGuess('time', array(), Guess::HIGH_CONFIDENCE); | 
            ||
| 75 | default:  | 
            ||
| 76 |                 return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); | 
            ||
| 77 | }  | 
            ||
| 78 | }  | 
            ||
| 79 | }  | 
            ||
| 80 | 
This checks looks for assignemnts to variables using the
list(...)function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$aand$care used. There was no need to assign$b.Instead, the list call could have been.