| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 53 | 5 | public static function fromJson($response) |
|
| 54 | { |
||
| 55 | 5 | $response = json_decode($response, true); |
|
| 56 | |||
| 57 | 5 | if (!is_array($response)) { |
|
| 58 | 3 | throw new \InvalidArgumentException('Invalid JSON provided'); |
|
| 59 | } |
||
| 60 | |||
| 61 | 2 | $responseObject = new self(); |
|
| 62 | |||
| 63 | 2 | foreach ($responseObject as $key => $value) { |
|
| 64 | 2 | if (isset($response[$key])) { |
|
| 65 | 2 | $responseObject->$key = $response[$key]; |
|
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | 2 | return $responseObject; |
|
| 70 | } |
||
| 72 |