Conditions | 4 |
Paths | 3 |
Total Lines | 25 |
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 | parent::__construct( |
||
42 | array_map( |
||
43 | function ($child) use ($class) { |
||
44 | return new $class($child); |
||
45 | }, |
||
46 | $items |
||
47 | ), |
||
48 | self::ARRAY_AS_PROPS |
||
49 | ); |
||
52 |