public function testToArray() { $sUT = new Schema(); $sUT->addProperty('test', new Property()); $sUT->addItem('test', new Item()); $this->assertInternalType('array', $sUT->toArray()); }
/** * @param string $key * @param JSONSchema\Structure\Property $property * @return $this */ protected function appendProperty($key, Property $property) { if (!isset($this->schemaObject)) { throw new NoStructureFoundException("The Schema is not attached or is not initialized. "); } $this->schemaObject->addProperty($key, $property); return $this; }
/** * (non-PHPdoc) * @see JSONSchema\Parsers.Parser::parse() */ protected function doParse($subject, Schema $schema) { if (null === ($jsonObj = json_decode($subject))) { throw new Exceptions\UnprocessableSubjectException("The JSONString subject was not processable - decode failed "); } // start walking the object foreach ($jsonObj as $key => $property) { $schema->addProperty($key, $this->determineProperty($property, $key, $schema), $schema->getConfig()->isRequiredDefault()); } return $schema; }