| Conditions | 16 |
| Paths | 18 |
| Total Lines | 29 |
| Code Lines | 21 |
| 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 |
||
| 29 | public function executeHandlers($value) |
||
| 30 | { |
||
| 31 | $handlers = $this->mode == RunningSuit::OUTPUT_MODE ? $this->propertyData->getOutputHandlers() : $this->propertyData->getInputHandlers(); |
||
| 32 | foreach ($handlers as $handler) { |
||
| 33 | if (strpos($handler, '`') !== false) { |
||
| 34 | $handler = str_replace('\\`', '`', substr($handler, 1, strlen($handler) - 2)); |
||
| 35 | if (is_null($this->object)) { |
||
| 36 | $value = call_user_func("{$this->class}::__axessorsExecute", $handler, $value, false); |
||
| 37 | } else { |
||
| 38 | $value = $this->object->__axessorsExecute($handler, $value, false); |
||
| 39 | } |
||
| 40 | } else { |
||
| 41 | foreach ($this->propertyData->getTypeTree() as $type => $subType) { |
||
| 42 | $reflection = new \ReflectionClass('\Axessors\Types\\' . is_int($type) ? $subType : $type); |
||
| 43 | foreach ($reflection->getMethods() as $method) { |
||
| 44 | $isAccessible = $method->isPublic() && $method->isStatic() && !$method->isAbstract(); |
||
| 45 | $isThat = call_user_func([$reflection->name, 'is'], $value); |
||
| 46 | if ($isAccessible && $isThat && "h_$handler" == $method->name) { |
||
| 47 | $value = call_user_func([$reflection->name, $method->name], $value, false); |
||
| 48 | continue 3; |
||
| 49 | } elseif ($isAccessible && "h_$handler" == $method->name && !$isThat) { |
||
| 50 | continue 3; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | throw new OopError("property {$this->class}::\${$this->propertyData->getName()} does not have handler \"$handler\""); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | return $value; |
||
| 58 | } |
||
| 59 | } |