Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Untyped | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| fromJSON | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | namespace Ably\Models; |
| 3 | |
| 4 | /** |
| 5 | * Blank model used in untyped PaginatedResult requests |
| 6 | */ |
| 7 | class Untyped { |
| 8 | /** |
| 9 | * Populates the model from JSON |
| 10 | * @param string|stdClass $json JSON string or an already decoded object. |
| 11 | * @throws AblyException |
| 12 | */ |
| 13 | public function fromJSON( $json ) { |
| 14 | if (is_object( $json )) { |
| 15 | $obj = $json; |
| 16 | } else { |
| 17 | $obj = @json_decode($json); |
| 18 | if (!$obj) { |
| 19 | throw new AblyException( 'Invalid object or JSON encoded object' ); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | foreach ( $obj as $key => $value ) { |
| 24 | $this->$key = $value; |
| 25 | } |
| 26 | } |
| 27 | } |