public function testReturnsAllMembers() { $s = new StructureShape(['members' => ['foo' => ['type' => 'string'], 'baz' => ['type' => 'integer']]], new ShapeMap([])); $members = $s->getMembers(); $this->assertInternalType('array', $members); $this->assertInstanceOf('Vws\\Api\\Shape', $members['foo']); $this->assertInstanceOf('Vws\\Api\\Shape', $members['baz']); $this->assertEquals('string', $members['foo']->getType()); $this->assertEquals('integer', $members['baz']->getType()); }
private function extractPayload($payload, StructureShape $output, ResponseInterface $response, array &$result) { $member = $output->getMember($payload); if ($member instanceof StructureShape) { // Structure members parse top-level data into a specific key. $result[$payload] = []; $this->payload($response, $member, $result[$payload]); } else { // Streaming data is just the stream from the response body. $result[$payload] = $response->getBody(); } }
private function check_structure(StructureShape $shape, $value) { if (!$this->checkAssociativeArray($value)) { return; } if ($shape['required']) { foreach ($shape['required'] as $req) { if (!isset($value[$req])) { $this->path[] = $req; $this->addError('is missing and is a required parameter'); array_pop($this->path); } } } foreach ($value as $name => $v) { if ($shape->hasMember($name)) { $this->path[] = $name; $this->dispatch($shape->getMember($name), isset($value[$name]) ? $value[$name] : null); array_pop($this->path); } } }