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