Conditions | 13 |
Paths | 13 |
Total Lines | 23 |
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 |
||
15 | public function __construct($className, $namespace = "", $isArray = false) { |
||
16 | parent::__construct($namespace); |
||
17 | $this->_isArray = $isArray; |
||
18 | $this->_isScalar = false; |
||
19 | if (count($this->parts) === 0) { |
||
|
|||
20 | switch ($className) { |
||
21 | case "int": |
||
22 | case "string": |
||
23 | case "float": |
||
24 | case "array": |
||
25 | case "mixed": |
||
26 | case "void": |
||
27 | case "object": |
||
28 | case "bool": |
||
29 | case "null": |
||
30 | case "false": |
||
31 | case "true": |
||
32 | $this->_isScalar = true; |
||
33 | break; |
||
34 | } |
||
35 | } |
||
36 | $this->addPart($className); |
||
37 | } |
||
38 | |||
77 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.