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