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 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); } } }