| Conditions | 17 |
| Paths | 17 |
| Total Lines | 38 |
| Code Lines | 30 |
| 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 |
||
| 102 | public function getHandler(string $nodeName, array $args = []) |
||
| 103 | { |
||
| 104 | switch ($nodeName) { |
||
| 105 | case 'id': |
||
| 106 | case 'lang': |
||
| 107 | case 'rights': |
||
| 108 | case 'subtitle': |
||
| 109 | case 'summary': |
||
| 110 | case 'title': |
||
| 111 | return $this->getScalarSingleValue($this->getRoot(), $nodeName, $args[0] ?? null); |
||
| 112 | |||
| 113 | case 'published': |
||
| 114 | case 'updated': |
||
| 115 | return (new DateParser( |
||
| 116 | $this->getScalarSingleValue($this->getRoot(), $nodeName, $args[0] ?? null)->getValue(), |
||
| 117 | $this->outputTimezone, |
||
| 118 | $this->createFromFormat |
||
| 119 | ))->getDateTime(); |
||
| 120 | |||
| 121 | case 'author': |
||
| 122 | return $this->getComplexSingleValue($this->getRoot(), $nodeName, Person::class, $args[0] ?? null); |
||
| 123 | |||
| 124 | case 'generator': |
||
| 125 | return $this->getComplexSingleValue($this->getRoot(), $nodeName, Generator::class, $args[0] ?? null); |
||
| 126 | |||
| 127 | case 'icon': |
||
| 128 | case 'logo': |
||
| 129 | return $this->getComplexSingleValue($this->getRoot(), $nodeName, Image::class, $args[0] ?? null); |
||
| 130 | |||
| 131 | case 'category': |
||
| 132 | case 'contributor': |
||
| 133 | case 'entry': |
||
| 134 | case 'link': |
||
| 135 | return $this->getComplexMultipleValues($this->getRoot(), $nodeName, $args[0] ?? null); |
||
| 136 | |||
| 137 | default: |
||
| 138 | throw new SimplePieException( |
||
| 139 | $this->getUnresolvableMessage($nodeName) |
||
| 140 | ); |
||
| 146 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..