| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class ZanzaraMapper |
||
| 16 | { |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var JsonMapper |
||
| 20 | */ |
||
| 21 | private $jsonMapper; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param JsonMapper $jsonMapper |
||
| 25 | */ |
||
| 26 | public function __construct(JsonMapper $jsonMapper) |
||
| 27 | { |
||
| 28 | $this->jsonMapper = $jsonMapper; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param string $json |
||
| 33 | * @param $class |
||
| 34 | * @return mixed |
||
| 35 | * @throws JsonMapper_Exception |
||
| 36 | */ |
||
| 37 | public function mapJson(string $json, $class) |
||
| 38 | { |
||
| 39 | $decoded = json_decode($json); |
||
| 40 | return is_array($decoded) ? |
||
| 41 | $this->jsonMapper->mapArray($decoded, [], $class) : |
||
| 42 | $this->jsonMapper->map($decoded, new $class); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param $object |
||
| 47 | * @param $class |
||
| 48 | * @return mixed |
||
| 49 | * @throws JsonMapper_Exception |
||
| 50 | */ |
||
| 51 | public function mapObject($object, $class) |
||
| 56 | } |
||
| 57 | |||
| 58 | } |
||
| 59 |