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