| Conditions | 10 |
| Paths | 4 |
| Total Lines | 47 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 42 | public function parse(){ |
||
| 43 | $reflect=new \ReflectionClass($this->class); |
||
| 44 | $parts=[$reflect->getShortName()]; |
||
| 45 | |||
| 46 | if($this->displayProperties){ |
||
| 47 | $prikeys=OrmUtils::getKeyFields($this->class); |
||
| 48 | $types=OrmUtils::getFieldTypes($this->class); |
||
| 49 | $propertiesArray=[]; |
||
| 50 | $properties=$reflect->getProperties(); |
||
| 51 | foreach ($properties as $property){ |
||
| 52 | $propertyName=$property->getName(); |
||
| 53 | $type="";$isPri=""; |
||
| 54 | if($this->displayPropertiesTypes){ |
||
| 55 | if(\array_key_exists($propertyName, $types)){ |
||
| 56 | $type=Yuml::$parameterTypeSeparator.$types[$propertyName]; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | if(\array_search($propertyName, $prikeys)!==false){ |
||
| 60 | $isPri=Yuml::$primary; |
||
| 61 | } |
||
| 62 | $propertiesArray[]=Yuml::setPropertyVariables([$this->getAccess($property),$isPri,$propertyName,$type]); |
||
| 63 | } |
||
| 64 | $parts[]=\implode(Yuml::$memberSeparator, $propertiesArray); |
||
| 65 | } |
||
| 66 | |||
| 67 | if($this->displayMethods){ |
||
| 68 | $methodsArray=[]; |
||
| 69 | $methods=$reflect->getMethods(); |
||
| 70 | foreach ($methods as $method){ |
||
| 71 | $parameters=""; |
||
| 72 | if($this->displayMethodsParams){ |
||
| 73 | $parameters=$this->getMethodParameters($method); |
||
| 74 | } |
||
| 75 | $methodName=$method->getName(); |
||
|
1 ignored issue
–
show
|
|||
| 76 | $type=""; |
||
| 77 | if($method->hasReturnType()){ |
||
| 78 | $type=Yuml::$parameterTypeSeparator.$method->getReturnType(); |
||
| 79 | } |
||
| 80 | $methodsArray[]=Yuml::setMethodVariables([$this->getAccess($method),$methodName,$parameters,$type]); |
||
| 81 | } |
||
| 82 | $parts[]=\implode(Yuml::$memberSeparator, $methodsArray); |
||
| 83 | } |
||
| 84 | |||
| 85 | $result=\implode(Yuml::$classSeparator, $parts); |
||
| 86 | $result=Yuml::setClassContent($result); |
||
| 87 | return $result; |
||
| 88 | } |
||
| 89 | |||
| 192 | } |