| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class StringVal implements SanitizeRuleInterface |
||
| 6 | { |
||
| 7 | /** @var null */ |
||
| 8 | protected $find; |
||
| 9 | |||
| 10 | /** @var null */ |
||
| 11 | protected $replace; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param string|array $find Find this/these in the value. |
||
| 15 | * @param string|array $replace Replace with this/these in the value. |
||
| 16 | * |
||
| 17 | */ |
||
| 18 | 9 | public function __construct($find = null, $replace = null) |
|
| 19 | { |
||
| 20 | 9 | $this->find = $find; |
|
| 21 | 9 | $this->replace = $replace; |
|
| 22 | 9 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Forces the value to a string, optionally applying `str_replace()`. |
||
| 26 | * |
||
| 27 | * @param object $subject The subject to be filtered. |
||
| 28 | * @param string $field The subject field name. |
||
| 29 | * |
||
| 30 | * @return bool True if the value was sanitized, false if not. |
||
| 31 | */ |
||
| 32 | 9 | public function __invoke($subject, string $field): bool |
|
| 41 | } |
||
| 42 | } |
||
| 43 |