| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 12 |
| Ratio | 100 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | 4 | public function __construct($maxLength) |
|
| 12 | { |
||
| 13 | 4 | $this->message = 'This field exceeds maximum length.'; |
|
| 14 | |||
| 15 | 4 | if (! is_int($maxLength)) { |
|
| 16 | 1 | throw new \InvalidArgumentException( |
|
| 17 | 1 | sprintf('Maximum length must be type of int, %s given.', gettype($maxLength)) |
|
| 18 | 1 | ); |
|
| 19 | } |
||
| 20 | |||
| 21 | 3 | $this->maxLength = $maxLength; |
|
| 22 | 3 | } |
|
| 23 | |||
| 29 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.