| Conditions | 4 |
| Paths | 3 |
| Total Lines | 30 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | public function __construct($class, $body) |
||
| 25 | { |
||
| 26 | // Links will not be available if we create a CollectionResponse manually within |
||
| 27 | // a GenericResponse e.g. a TeamsResponse as part of a MemberResponse. |
||
| 28 | if (is_object($body)) { |
||
| 29 | $this->links = $body->_links; |
||
| 30 | |||
| 31 | if (!property_exists($body, '_embedded') || !property_exists($body->_embedded, 'items')) { |
||
| 32 | throw new \Exception('CollectionResponse does not contain embedded items.'); |
||
| 33 | } |
||
| 34 | $items = $body->_embedded->items; |
||
| 35 | } else { |
||
| 36 | $items = $body; |
||
| 37 | } |
||
| 38 | |||
| 39 | $class = '\AcquiaCloudApi\Response\\' . $class; |
||
| 40 | |||
| 41 | |||
| 42 | // var_dump($body); |
||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | parent::__construct( |
||
| 47 | array_map( |
||
| 48 | function ($child) use ($class) { |
||
| 49 | return new $class($child); |
||
| 50 | }, |
||
| 51 | $items |
||
| 52 | ), |
||
| 53 | self::ARRAY_AS_PROPS |
||
| 54 | ); |
||
| 57 |