| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | class ModelParams |
||
| 26 | { |
||
| 27 | 42 | public static function getType($type) |
|
| 28 | { |
||
| 29 | 42 | $string_pattern = static::getStringPattern(); |
|
| 30 | 42 | $int_pattern = '/.*int(?:eger)?\(\d+\).*/i'; |
|
| 31 | 42 | $float_pattern = static::getFloatPattern(); |
|
| 32 | |||
| 33 | switch (1) { |
||
| 34 | 42 | case preg_match($string_pattern, $type): |
|
| 35 | 20 | return Type::STRING; |
|
| 36 | 22 | case preg_match($int_pattern, $type): |
|
| 37 | 10 | return Type::INT; |
|
| 38 | 12 | case preg_match($float_pattern, $type): |
|
| 39 | 10 | return Type::FLOAT; |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | throw new \RuntimeException('Unknown data type'); |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Getting string pattern |
||
| 47 | * |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | 40 | protected static function getStringPattern() |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Getting float pattern |
||
| 63 | * |
||
| 64 | * @return string |
||
| 65 | */ |
||
| 66 | 40 | protected static function getFloatPattern() |
|
| 75 |