| Total Complexity | 13 |
| Total Lines | 83 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | abstract class AbstractParser implements ParserInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $data = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @return bool |
||
| 18 | */ |
||
| 19 | public function isEmpty() |
||
| 20 | { |
||
| 21 | return !$this->data; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param $key |
||
| 26 | * @return string|null|array |
||
| 27 | */ |
||
| 28 | protected function getValue($key) |
||
| 29 | { |
||
| 30 | if (isset($this->data[$key])) { |
||
| 31 | return $this->data[$key]; |
||
| 32 | } |
||
| 33 | |||
| 34 | return null; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param $key |
||
| 39 | * @return int|string |
||
| 40 | */ |
||
| 41 | protected function getDivisionValue($key) |
||
| 42 | { |
||
| 43 | $value = $this->getValue($key); |
||
| 44 | if (strpos($value, '/1') !== false) { |
||
|
|
|||
| 45 | return (int) str_replace('/1', '', $value); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $value; |
||
| 49 | |||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param $key |
||
| 54 | * @return bool|null |
||
| 55 | */ |
||
| 56 | protected function getBooleanValue($key) |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param $data |
||
| 68 | * @return string|null |
||
| 69 | */ |
||
| 70 | protected function removeEmptyData($data) |
||
| 71 | { |
||
| 72 | if (is_string($data) and $data == '') { |
||
| 73 | return null; |
||
| 74 | } |
||
| 75 | |||
| 76 | return $data; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param $key |
||
| 81 | * @return string|null |
||
| 82 | */ |
||
| 83 | protected function getSingleValue($key) |
||
| 92 | } |
||
| 93 | } |
||
| 94 |