| Conditions | 14 |
| Paths | 40 |
| Total Lines | 61 |
| Code Lines | 44 |
| 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 |
||
| 47 | public function parse(){ |
||
| 48 | $reflect=new \ReflectionClass($this->class); |
||
| 49 | $yumlAnnot=OrmUtils::getAnnotationInfo($this->class, "#yuml"); |
||
| 50 | $color=""; |
||
| 51 | if ($yumlAnnot!==false){ |
||
| 52 | if(isset($yumlAnnot["color"])){ |
||
| 53 | $color="{bg:".$yumlAnnot["color"]."}"; |
||
| 54 | } |
||
| 55 | if(isset($yumlAnnot["note"])){ |
||
| 56 | $this->note=$yumlAnnot["note"]; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | $parts=[$reflect->getShortName()]; |
||
| 60 | |||
| 61 | if($this->displayProperties){ |
||
| 62 | $prikeys=OrmUtils::getKeyFields($this->class); |
||
| 63 | $types=OrmUtils::getFieldTypes($this->class); |
||
| 64 | $propertiesArray=[]; |
||
| 65 | $properties=$reflect->getProperties(); |
||
| 66 | foreach ($properties as $property){ |
||
| 67 | $propertyName=$property->getName(); |
||
| 68 | $type="";$isPri=""; |
||
| 69 | if($this->displayPropertiesTypes){ |
||
| 70 | if(\array_key_exists($propertyName, $types)){ |
||
| 71 | $type=Yuml::$parameterTypeSeparator.$types[$propertyName]; |
||
| 72 | } |
||
| 73 | } |
||
| 74 | if(\array_search($propertyName, $prikeys)!==false){ |
||
| 75 | $isPri=Yuml::$primary; |
||
| 76 | } |
||
| 77 | $propertiesArray[]=Yuml::setPropertyVariables([$this->getAccess($property),$isPri,$propertyName,$type]); |
||
| 78 | } |
||
| 79 | $parts[]=\implode(Yuml::$memberSeparator, $propertiesArray); |
||
| 80 | } |
||
| 81 | |||
| 82 | if($this->displayMethods){ |
||
| 83 | $methodsArray=[]; |
||
| 84 | $methods=$reflect->getMethods(); |
||
| 85 | foreach ($methods as $method){ |
||
| 86 | $parameters=""; |
||
| 87 | if($this->displayMethodsParams){ |
||
| 88 | $parameters=$this->getMethodParameters($method); |
||
| 89 | } |
||
| 90 | $methodName=$method->getName(); |
||
| 91 | $type=""; |
||
| 92 | if($method->hasReturnType()){ |
||
| 93 | $type=Yuml::$parameterTypeSeparator.$method->getReturnType(); |
||
| 94 | } |
||
| 95 | $methodsArray[]=Yuml::setMethodVariables([$this->getAccess($method),$methodName,$parameters,$type]); |
||
| 96 | } |
||
| 97 | $parts[]=\implode(Yuml::$memberSeparator, $methodsArray); |
||
| 98 | } |
||
| 99 | |||
| 100 | $result=\implode(Yuml::$classSeparator, $parts).$color; |
||
| 101 | $result=Yuml::setClassContent($result); |
||
| 102 | if(isset($this->note)){ |
||
| 103 | $result.=$this->_getNote(); |
||
| 104 | } |
||
| 105 | $this->parseResult=$result; |
||
| 106 | return $result; |
||
| 107 | } |
||
| 108 | |||
| 216 |