Conditions | 10 |
Paths | 34 |
Total Lines | 37 |
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 |
||
57 | public function initAnnotation(array $properties) |
||
58 | { |
||
59 | if (isset($properties[0])) { |
||
60 | if (isset($properties[1])) { |
||
61 | $this->method = (array) $properties[0]; |
||
62 | |||
63 | if (! is_string($properties[1])) { |
||
64 | throw new AnnotationException('RequestMappingAnnotation requires a string as path property'); |
||
65 | } |
||
66 | |||
67 | $this->path = $properties[1]; |
||
68 | |||
69 | unset($properties[1]); |
||
70 | } else { |
||
71 | if (is_string($properties[0])) { |
||
72 | $this->path = $properties[0]; |
||
73 | } elseif (is_array($properties[0])) { |
||
74 | $this->method = $properties[0]; |
||
75 | } else { |
||
76 | throw new AnnotationException('Invalid type for RequestMappingAnnotation properties'); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | unset($properties[0]); |
||
81 | } |
||
82 | |||
83 | parent::initAnnotation($properties); |
||
84 | |||
85 | if ($this->method === ['*']) { |
||
86 | $this->method = null; |
||
87 | } |
||
88 | if (! empty($this->method)) { |
||
89 | $this->method = array_map('strtoupper', $this->method); |
||
90 | |||
91 | foreach ($this->method as $method) { |
||
92 | if (! in_array($method, self::VALID_METHODS, true)) { |
||
93 | throw new AnnotationException('`' . $method . '` is not a valid method for RequestMappingAnnotation'); |
||
94 | } |
||
99 |