public function testType() { $this->assertEquals(PropertyTypeMapper::STRING_TYPE, PropertyTypeMapper::map('im string !')); $this->assertEquals(PropertyTypeMapper::NUMBER_TYPE, PropertyTypeMapper::map(10.2)); $this->assertEquals(PropertyTypeMapper::INTEGER_TYPE, PropertyTypeMapper::map(10)); $this->assertEquals(PropertyTypeMapper::INTEGER_TYPE, PropertyTypeMapper::map(0)); $this->assertEquals(PropertyTypeMapper::INTEGER_TYPE, PropertyTypeMapper::map(1)); $this->assertEquals(PropertyTypeMapper::NULL_TYPE, PropertyTypeMapper::map(null)); $this->assertEquals(PropertyTypeMapper::BOOLEAN_TYPE, PropertyTypeMapper::map(true)); $this->assertEquals(PropertyTypeMapper::BOOLEAN_TYPE, PropertyTypeMapper::map(false)); $this->assertEquals(PropertyTypeMapper::ARRAY_TYPE, PropertyTypeMapper::map(array())); $this->assertEquals(PropertyTypeMapper::OBJECT_TYPE, PropertyTypeMapper::map(new \stdClass())); }
/** * @param mixed $property * @param Item $item * @return Item */ private function determineChildItem($property, Item $item, Schema $schema) { if (PropertyTypeMapper::map($property) === PropertyTypeMapper::OBJECT_TYPE) { foreach (get_object_vars($property) as $key => $itemzz) { $item->addProperty($key, $this->determineProperty($itemzz, $key, $schema), $schema->getConfig()->isRequiredDefault()); } } return $item; }