| Conditions | 11 |
| Paths | 12 |
| Total Lines | 29 |
| Code Lines | 16 |
| 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 |
||
| 41 | public function initAnnotation(array $properties) |
||
| 42 | { |
||
| 43 | if (isset($properties[0])) { |
||
| 44 | if (isset($properties[1])) { |
||
| 45 | $this->min = $properties[0]; |
||
| 46 | $this->max = $properties[1]; |
||
| 47 | unset($properties[1]); |
||
| 48 | } else { |
||
| 49 | $this->max = $properties[0]; |
||
| 50 | } |
||
| 51 | |||
| 52 | unset($properties[0]); |
||
| 53 | } |
||
| 54 | |||
| 55 | parent::initAnnotation($properties); |
||
| 56 | |||
| 57 | if ($this->min !== null && ! is_int($this->min) && ! is_float($this->min)) { |
||
|
|
|||
| 58 | throw new AnnotationException('RangeAnnotation requires a numeric (float or int) min property'); |
||
| 59 | } |
||
| 60 | |||
| 61 | if ($this->max !== null && ! is_int($this->max) && ! is_float($this->max)) { |
||
| 62 | throw new AnnotationException('RangeAnnotation requires a numeric (float or int) max property'); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ($this->min === null && $this->max === null) { |
||
| 66 | throw new AnnotationException('RangeAnnotation requires a min and/or max property'); |
||
| 67 | } |
||
| 68 | |||
| 69 | $this->value = [$this->min, $this->max]; |
||
| 70 | } |
||
| 72 |