Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class Strlen extends AbstractStringCase implements SanitizeRuleInterface |
||
8 | { |
||
9 | /** @var int */ |
||
10 | protected $len; |
||
11 | |||
12 | /** @var string */ |
||
13 | protected $padString; |
||
14 | |||
15 | /** @var int */ |
||
16 | protected $padType; |
||
17 | |||
18 | /** |
||
19 | * @param int $len The string length. |
||
20 | * @param string $pad_string Pad using this string. |
||
21 | * @param int $pad_type A `STR_PAD_*` constant. |
||
22 | */ |
||
23 | 21 | public function __construct(int $len, string $padString = ' ', int $padType = STR_PAD_RIGHT) |
|
28 | 21 | } |
|
29 | |||
30 | /** |
||
31 | * Sanitizes a string to an exact length by padding or chopping it. |
||
32 | * |
||
33 | * @param object $subject The subject to be filtered. |
||
34 | * @param string $field The subject field name. |
||
35 | * |
||
36 | * @return bool True if the value was sanitized, false if not. |
||
37 | */ |
||
38 | 21 | public function __invoke($subject, string $field): bool |
|
54 |