| 1 | <?php |
||
| 8 | class SanitizeSpec extends AbstractSpec |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Value to use when inserting |
||
| 12 | * |
||
| 13 | * @var mixed |
||
| 14 | */ |
||
| 15 | protected $blankValue; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Failure mode for the rule. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $failureMode = 'HARD_FAILURE'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Invokes the rule the spec is configured for. |
||
| 26 | * |
||
| 27 | * @param object $subject |
||
| 28 | * |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | 24 | public function __invoke($subject): bool |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Set the Sanitize rule to be used. |
||
| 48 | * |
||
| 49 | * @param SanitizeRuleInterface $rule |
||
| 50 | * |
||
| 51 | * @return SanitizeSpec |
||
| 52 | */ |
||
| 53 | 21 | public function to(SanitizeRuleInterface $rule): self |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Sets the blank value to use. |
||
| 63 | * |
||
| 64 | * Defaults to null. |
||
| 65 | * |
||
| 66 | * @param $blankValue |
||
| 67 | * |
||
| 68 | * @return SanitizeSpec |
||
| 69 | */ |
||
| 70 | 9 | public function usingBlank($blankValue = null): self |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Returns the default failure message for this rule specification. |
||
| 80 | * |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | 6 | protected function getDefaultMessage(): string |
|
| 93 | } |
||
| 94 |