| Conditions | 10 |
| Paths | 160 |
| Total Lines | 20 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 36 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { |
||
| 37 | parent::__construct($attributes); |
||
| 38 | $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0; |
||
| 39 | $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; |
||
| 40 | $this->name = $name; |
||
| 41 | $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); |
||
| 42 | $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; |
||
| 43 | $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array(); |
||
| 44 | |||
| 45 | if ($this->type & Class_::MODIFIER_STATIC) { |
||
| 46 | switch (strtolower($this->name)) { |
||
| 47 | case '__construct': |
||
| 48 | throw new Error(sprintf('Constructor %s() cannot be static', $this->name)); |
||
| 49 | case '__destruct': |
||
| 50 | throw new Error(sprintf('Destructor %s() cannot be static', $this->name)); |
||
| 51 | case '__clone': |
||
| 52 | throw new Error(sprintf('Clone method %s() cannot be static', $this->name)); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 102 |