| Conditions | 12 |
| Paths | 42 |
| Total Lines | 31 |
| Code Lines | 23 |
| 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 |
||
| 22 | public static function runAction(array &$u, $initialize = true, $finalize = true): void { |
||
| 23 | self::$controller = $ctrl = $u [0]; |
||
| 24 | self::$action = $action = $u [1] ?? 'index'; |
||
| 25 | self::$actionParams = \array_slice ( $u, 2 ); |
||
| 26 | |||
| 27 | try { |
||
| 28 | if (null !== $controller = self::getControllerInstance ( $ctrl )) { |
||
| 29 | $binaryCalls = $controller->_binaryCalls ?? (self::IS_VALID & self::INITIALIZE & self::FINALIZE); |
||
| 30 | if (($binaryCalls & self::IS_VALID) && ! $controller->isValid ( $action )) { |
||
| 31 | $controller->onInvalidControl (); |
||
| 32 | } else { |
||
| 33 | if (($binaryCalls & self::INITIALIZE) && $initialize) { |
||
| 34 | $controller->initialize (); |
||
| 35 | } |
||
| 36 | try { |
||
| 37 | $controller->$action ( ...(self::$actionParams) ); |
||
| 38 | } catch ( \Error $e ) { |
||
| 39 | Logger::warn ( 'Startup', $e->getTraceAsString (), 'runAction' ); |
||
| 40 | if (self::$config ['debug']) { |
||
| 41 | throw $e; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | if (($binaryCalls & self::FINALIZE) && $finalize) { |
||
| 45 | $controller->finalize (); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } catch ( \Error $eC ) { |
||
| 50 | Logger::warn ( 'Startup', $eC->getTraceAsString (), 'runAction' ); |
||
| 51 | if (self::$config ['debug']) { |
||
| 52 | throw $eC; |
||
| 53 | } |
||
| 65 |