| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 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 | |||
| 65 | 2 | if(isset($response[$key])){ |
|
| 66 | |||
| 67 | 2 | $responseObject->$key = $response[$key]; |
|
| 68 | 2 | } |
|
| 69 | 2 | } |
|
| 70 | |||
| 71 | 2 | return $responseObject; |
|
| 72 | } |
||
| 73 | } |