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