| Conditions | 17 |
| Paths | 17 |
| Total Lines | 32 |
| Code Lines | 27 |
| 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 |
||
| 79 | public function shutdownHandler() |
||
| 80 | { |
||
| 81 | if ($error = error_get_last()) { |
||
| 82 | $errorMsg = $error['message'] . " " . $error['file'] . "(" . $error['line'] . ")"; |
||
| 83 | switch ($error['type']) { |
||
| 84 | case E_ERROR: |
||
| 85 | case E_CORE_ERROR: |
||
| 86 | case E_COMPILE_ERROR: |
||
| 87 | case E_USER_ERROR: |
||
| 88 | case E_RECOVERABLE_ERROR: |
||
| 89 | $this->container->logger->fatal($errorMsg); |
||
| 90 | break; |
||
| 91 | case E_PARSE: |
||
| 92 | $this->container->logger->error($errorMsg); |
||
| 93 | break; |
||
| 94 | case E_WARNING: |
||
| 95 | case E_CORE_WARNING: |
||
| 96 | case E_COMPILE_WARNING: |
||
| 97 | case E_USER_WARNING: |
||
| 98 | case E_STRICT: |
||
| 99 | case E_NOTICE: |
||
| 100 | case E_USER_NOTICE: |
||
| 101 | case E_DEPRECATED: |
||
| 102 | case E_USER_DEPRECATED: |
||
| 103 | $this->container->logger->warn($errorMsg); |
||
| 104 | break; |
||
| 105 | } |
||
| 106 | |||
| 107 | $this->container->logger->enableDirectWrite(); |
||
| 108 | $this->container->response->move(500); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.