| Conditions | 3 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 13 |
| Ratio | 100 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 11 | public function apply($instance, stdClass $schema, Context $context, Walker $walker) |
|
| 42 | { |
||
| 43 | 11 | $length = extension_loaded('mbstring') ? |
|
| 44 | 11 | mb_strlen($instance, mb_detect_encoding($instance)) : |
|
| 45 | 11 | strlen($instance); |
|
| 46 | |||
| 47 | 11 | if ($length > $schema->maxLength) { |
|
| 48 | 5 | $context->addViolation( |
|
| 49 | 5 | 'should be lesser than or equal to %s characters', |
|
| 50 | 5 | [$schema->maxLength] |
|
| 51 | 5 | ); |
|
| 52 | 5 | } |
|
| 53 | 11 | } |
|
| 54 | } |
||
| 55 |