| Conditions | 11 |
| Paths | 10 |
| Total Lines | 36 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 72 | private function isCallable($definition): bool |
||
| 73 | { |
||
| 74 | if ( |
||
| 75 | is_array($definition) |
||
| 76 | && array_keys($definition) === [0, 1] |
||
| 77 | && is_string($definition[0]) |
||
| 78 | ) { |
||
| 79 | if (class_exists($definition[0])) { |
||
| 80 | try { |
||
| 81 | $method = new ReflectionMethod($definition[0], $definition[1]); |
||
| 82 | if ($method->isStatic()) { |
||
| 83 | return true; |
||
| 84 | } |
||
| 85 | } catch (ReflectionException $exception) { |
||
| 86 | return false; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | if ($this->container->has($definition[0])) { |
||
| 91 | $object = $this->container->get($definition[0]); |
||
| 92 | |||
| 93 | return method_exists($object, $definition[1]); |
||
| 94 | } |
||
| 95 | |||
| 96 | return false; |
||
| 97 | } |
||
| 98 | |||
| 99 | if (is_callable($definition)) { |
||
| 100 | return true; |
||
| 101 | } |
||
| 102 | |||
| 103 | if (is_string($definition) && $this->container->has($definition)) { |
||
| 104 | return is_callable($this->container->get($definition)); |
||
| 105 | } |
||
| 106 | |||
| 107 | return false; |
||
| 108 | } |
||
| 110 |