1 | <?php |
||
6 | class RuleHelper |
||
7 | { |
||
8 | /** |
||
9 | * Method that parses the option variable and converts it into an array |
||
10 | * You can pass anything to a validator like: |
||
11 | * - a query string: 'min=3&max=5' |
||
12 | * - a JSON string: '{"min":3,"max":5}' |
||
13 | * - a CSV string: '5,true' (for this scenario the 'optionsIndexMap' property is required) |
||
14 | * |
||
15 | * @param mixed $options |
||
16 | * |
||
17 | * @return array |
||
18 | * @throws \InvalidArgumentException |
||
19 | */ |
||
20 | public static function normalizeOptions($options, array $optionsIndexMap = []) |
||
51 | |||
52 | /** |
||
53 | * Converts a HTTP query string to an array |
||
54 | * |
||
55 | * @param $str |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public static function parseHttpQueryString(string $str) |
||
65 | |||
66 | /** |
||
67 | * Converts 'true' and 'false' strings to TRUE and FALSE |
||
68 | * |
||
69 | * @param $arr |
||
70 | * |
||
71 | * @return bool|array |
||
72 | */ |
||
73 | public static function convertBooleanStrings($arr) |
||
87 | |||
88 | |||
89 | /** |
||
90 | * Parses a CSV string and converts the result into an "options" array |
||
91 | * (an associative array that contains the options for the validation rule) |
||
92 | * |
||
93 | * @param $str |
||
94 | * |
||
95 | * @param array $optionsIndexMap |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | public static function parseCsvString($str, array $optionsIndexMap = []) |
||
121 | |||
122 | /** |
||
123 | * Checks if an array is associative (ie: the keys are not numbers in sequence) |
||
124 | * |
||
125 | * @param array $arr |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | public static function arrayIsAssoc($arr) |
||
133 | |||
134 | public static function normalizeFileSize($size) |
||
148 | |||
149 | |||
150 | |||
151 | public static function normalizeImageRatio($ratio) |
||
164 | } |
||
165 |