File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 44
55namespace KaririCode \Sanitizer \Exception ;
66
7- final class SanitizationException extends \RuntimeException
7+ use KaririCode \Exception \AbstractException ;
8+
9+ final class SanitizationException extends AbstractException
810{
11+ private const CODE_INVALID_INPUT = 4001 ;
12+
13+ public static function invalidInput (string $ expectedType ): self
14+ {
15+ $ message = sprintf (
16+ 'Input must be a %s ' ,
17+ $ expectedType
18+ );
19+
20+ return self ::createException (
21+ self ::CODE_INVALID_INPUT ,
22+ 'INVALID_INPUT ' ,
23+ $ message
24+ );
25+ }
926}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ abstract class AbstractSanitizerProcessor implements Processor
1212 protected function guardAgainstNonString (mixed $ input ): string
1313 {
1414 if (!is_string ($ input )) {
15- throw new SanitizationException ( ' Input must be a string ' );
15+ throw SanitizationException:: invalidInput ( ' string ' );
1616 }
1717
1818 return $ input ;
You can’t perform that action at this time.
0 commit comments