public function testToArray() { $sUT = new Schema(); $sUT->addProperty('test', new Property()); $sUT->addItem('test', new Item()); $this->assertInternalType('array', $sUT->toArray()); }
/** * @param mixed $items * @param string $name * @return \JSONSchema\Structure\Item */ private function determineItem($items, $name, Schema $schema) { $baseUrl = $schema->getConfig()->getBaseUrl(); $additionalProperties = $schema->getConfig()->hasAdditionalProperties(); $type = PropertyTypeMapper::map($items); $retItem = new Item(); $retItem->setType($type); $retItem->setName($name); $retItem->setAdditionalProperties($additionalProperties); if ($baseUrl !== null) { $retItem->setId($baseUrl . '/' . $name); } return $this->determineChildItem($items, $retItem, $schema); }
/** * @param mixed $subject * @param Config $config * @return \JSONSchema\Structure\Schema */ public function parse($subject, Config $config = null) { $schemaObject = new Schema(); $schemaObject->setConfig($config === null ? new Config() : $config); return $this->doParse($subject, $schemaObject); }
/** * after a successful parse we want to return the json of the Schema * it should probably be compressed string * they can beautify it later or maybe we will need to add a beauty function * * @return string $json */ public function json() { return $this->schemaObject->toString(); }