public function testGetterSetter() { $sUT = new Property(); $id = 'test'; $type = 'im'; $name = ','; $title = 'super'; $description = 'super !'; $required = 'key'; $min = 10; $max = 11; $sUT->setId($id); $sUT->setType($type); $sUT->setName($name); $sUT->setTitle($title); $sUT->setDescription($description); $sUT->addRequired($required); $sUT->setMin($min); $sUT->setMax($max); $this->assertEquals($id, $sUT->getId()); $this->assertEquals($type, $sUT->getType()); $this->assertEquals($name, $sUT->getName()); $this->assertEquals($title, $sUT->getTitle()); $this->assertEquals($description, $sUT->getDescription()); $this->assertEquals(array($required), $sUT->getRequired()); $this->assertEquals($min, $sUT->getMin()); $this->assertEquals($max, $sUT->getMax()); }
/** * @param mixed $property * @param string $name * @return \JSONSchema\Structure\Property */ private function determineProperty($property, $name, Schema $schema) { $baseUrl = $schema->getConfig()->getBaseUrl(); $additionalProperties = $schema->getConfig()->hasAdditionalProperties(); $type = PropertyTypeMapper::map($property); $prop = new Property(); $prop->setType($type)->setName($name)->setAdditionalProperties($additionalProperties); if ($baseUrl !== null) { $prop->setId($baseUrl . '/' . $name); } return $this->determineChildProperty($type, $property, $prop, $schema); }
/** * due to the fact that determining property will be so different between * parser types we should probably just define this function here * In a JSON string it will be very simple. * enter a string * see what the string looks like * check the maps of types * see if it fits some semantics * * @param object $property * @return Property */ protected function determineProperty($property, $name) { $baseUrl = $this->configKeyExists('baseUrl') ? $this->getConfigSetting('baseUrl') : null; $requiredDefault = $this->configKeyExists('requiredDefault') ? $this->getConfigSetting('requiredDefault') : false; $type = StringMapper::map($property); if ($type == StringMapper::ARRAY_TYPE) { return $this->determineItem($property, $name); } $prop = new Property(); $prop->setType($type)->setName($name)->setKey($name)->setRequired($requiredDefault); if ($baseUrl) { $prop->setId($baseUrl . '/' . $name); } // since this is an object get the properties of the sub objects if ($type == StringMapper::ARRAY_TYPE) { $prop->addItem($name, $this->determineItem($property, $name)); } elseif ($type == StringMapper::OBJECT_TYPE) { foreach ($property as $key => $newProperty) { $prop->addProperty($key, $this->determineProperty($newProperty, $key)); } } return $prop; }