| Conditions | 12 |
| Paths | 17 |
| Total Lines | 27 |
| Code Lines | 23 |
| 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 |
||
| 62 | public function __construct($filePath) |
||
| 63 | { |
||
| 64 | if (is_object($filePath)) { |
||
|
|
|||
| 65 | if ($filePath instanceof \O2System\Kernel\Cli\Commander) { |
||
| 66 | parent::__construct($filePath); |
||
| 67 | $this->instance = $filePath; |
||
| 68 | } |
||
| 69 | } elseif (is_string($filePath) && is_file($filePath)) { |
||
| 70 | $className = prepare_class_name(pathinfo($filePath, PATHINFO_FILENAME)); |
||
| 71 | @list($namespaceDirectory, $subNamespace) = explode('Commanders', dirname($filePath)); |
||
| 72 | $classNamespace = loader()->getDirNamespace( |
||
| 73 | $namespaceDirectory |
||
| 74 | ) . 'Commanders' . (empty($subNamespace) ? null : str_replace('/', '\\', $subNamespace)) . '\\'; |
||
| 75 | $className = $classNamespace . $className; |
||
| 76 | |||
| 77 | if (class_exists('\O2System\Kernel\Cli\\' . $className)) { |
||
| 78 | parent::__construct('\O2System\Kernel\Cli\\' . $className); |
||
| 79 | } elseif (class_exists('\O2System\Framework\Cli\\' . $className)) { |
||
| 80 | parent::__construct('\O2System\Framework\Cli\\' . $className); |
||
| 81 | } elseif (class_exists('\O2System\Reactor\Cli\\' . $className)) { |
||
| 82 | parent::__construct('\O2System\Reactor\Cli\\' . $className); |
||
| 83 | } elseif (class_exists('\App\Cli\\' . $className)) { |
||
| 84 | parent::__construct('\App\Cli\\' . $className); |
||
| 85 | } elseif (class_exists('\App\\' . $className)) { |
||
| 86 | parent::__construct('\App\\' . $className); |
||
| 87 | } elseif (class_exists($className)) { |
||
| 88 | parent::__construct($className); |
||
| 89 | } |
||
| 205 | } |