| Conditions | 11 |
| Paths | 18 |
| Total Lines | 29 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 132 |
| 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 |
||
| 24 | public function check($value): bool |
||
| 25 | { |
||
| 26 | $this->requireParameters($this->fillableParams); |
||
| 27 | |||
| 28 | if (is_int($value) || is_float($value)) { |
||
| 29 | $value = (string) $value; |
||
| 30 | } |
||
| 31 | |||
| 32 | if (! is_string($value)) { |
||
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | if (! is_numeric($compare = $this->parameter('value'))) { |
||
| 37 | $compare = $this->getAttribute()->getValue($compare); |
||
| 38 | } |
||
| 39 | |||
| 40 | if (! is_numeric($value) || ! is_numeric($compare) || ((int) $compare === 0 && (int) $value === 0)) { |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | |||
| 44 | if ((int) $value === 0) { |
||
| 45 | return true; |
||
| 46 | } |
||
| 47 | |||
| 48 | if ((int) $compare === 0) { |
||
| 49 | return false; |
||
| 50 | } |
||
| 51 | |||
| 52 | return $value % $compare === 0; |
||
| 53 | } |
||
| 55 |