1 | <?php |
||
11 | final class Strings |
||
12 | { |
||
13 | /** |
||
14 | * Filter a string. |
||
15 | * |
||
16 | * Verify that the passed in value is a string. By default, nulls are not allowed, and the length is restricted |
||
17 | * between 1 and PHP_INT_MAX. These parameters can be overwritten for custom behavior. |
||
18 | * |
||
19 | * The return value is the string, as expected by the \DominionEnterprises\Filterer class. |
||
20 | * |
||
21 | * @param mixed $value The value to filter. |
||
22 | * @param bool $allowNull True to allow nulls through, and false (default) if nulls should not be allowed. |
||
23 | * @param int $minLength Minimum length to allow for $value. |
||
24 | * @param int $maxLength Maximum length to allow for $value. |
||
25 | * @return string|null The passed in $value. |
||
26 | * |
||
27 | * @throws \Exception if the value did not pass validation. |
||
28 | * @throws \InvalidArgumentException if one of the parameters was not correctly typed. |
||
29 | */ |
||
30 | public static function filter($value, $allowNull = false, $minLength = 1, $maxLength = PHP_INT_MAX) |
||
76 | |||
77 | /** |
||
78 | * Explodes a string into an array using the given delimiter. |
||
79 | * |
||
80 | * For example, given the string 'foo,bar,baz', this would return the array ['foo', 'bar', 'baz']. |
||
81 | * |
||
82 | * @param string $value The string to explode. |
||
83 | * @param string $delimiter The non-empty delimiter to explode on. |
||
84 | * @return array The exploded values. |
||
85 | * |
||
86 | * @throws \Exception if the value is not a string. |
||
87 | * @throws \InvalidArgumentException if the delimiter does not pass validation. |
||
88 | */ |
||
89 | public static function explode($value, $delimiter = ',') |
||
103 | } |
||
104 |