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