| Total Complexity | 8 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait DefaultTypes |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Supported types of URL parameters |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $types = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Method handles integer type |
||
| 21 | * |
||
| 22 | * @param string $value |
||
| 23 | * value to be parsed |
||
| 24 | * @return bool was the value parsed |
||
| 25 | */ |
||
| 26 | public static function intHandler(string &$value): bool |
||
| 27 | { |
||
| 28 | if (is_numeric($value)) { |
||
| 29 | $value = $value + 0; |
||
| 30 | return true; |
||
| 31 | } |
||
| 32 | |||
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Method handles command type |
||
| 38 | * |
||
| 39 | * @param string $value |
||
| 40 | * value to be parsed |
||
| 41 | * @return bool was the value parsed |
||
| 42 | */ |
||
| 43 | public static function commandHandler(string &$value): bool |
||
| 44 | { |
||
| 45 | if (preg_match('/^([a-z0-9A-Z_\/\-\.\@]+)$/', $value)) { |
||
| 46 | return true; |
||
| 47 | } |
||
| 48 | |||
| 49 | return false; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Method handles list of integers type |
||
| 54 | * |
||
| 55 | * @param string $value |
||
| 56 | * value to be parsed |
||
| 57 | * @return bool was the value parsed |
||
| 58 | */ |
||
| 59 | public static function intListHandler(string &$value): bool |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Method handles string type |
||
| 70 | * |
||
| 71 | * @param string $value |
||
| 72 | * value to be parsed |
||
| 73 | * @return bool was the value parsed |
||
| 74 | */ |
||
| 75 | public static function stringHandler(string &$value): bool |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Init types |
||
| 84 | */ |
||
| 85 | protected function initDefaultTypes() |
||
| 91 | } |
||
| 92 | } |
||
| 93 |