public function testReturnsMember() { $s = new StructureShape(['members' => ['foo' => ['type' => 'string']]], new ShapeMap([])); $this->assertTrue($s->hasMember('foo')); $this->assertInstanceOf('Vws\\Api\\Shape', $s->getMember('foo')); $this->assertEquals('string', $s->getMember('foo')->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); } } }