| Conditions | 10 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 38 | public function __construct($minimum = 0, $maximum = null, $base = 10) |
||
| 39 | { |
||
| 40 | if ($minimum !== null && !is_int($minimum)) { |
||
| 41 | throw new \Exception('Minimum must be integer or `null`'); |
||
| 42 | } |
||
| 43 | |||
| 44 | if ($maximum !== null && !is_int($maximum)) { |
||
| 45 | throw new \Exception('Maximum must be integer or `null`'); |
||
| 46 | } |
||
| 47 | |||
| 48 | if ($minimum !== null && $maximum !== null && $minimum > $maximum) { |
||
| 49 | throw new \Exception('Maximum must be greater than minimum'); |
||
| 50 | } |
||
| 51 | |||
| 52 | $this->minimum = $minimum; |
||
| 53 | $this->maximum = $maximum; |
||
| 54 | |||
| 55 | $this->base = intval($base); |
||
| 56 | if ($base < 2 || $base > strlen(self::$set)) { |
||
| 57 | throw new \Exception('Invalid base'); |
||
| 58 | } |
||
| 94 |