/**
  * @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);
 }
 public function testGetterSetter()
 {
     $sUT = new Item();
     $id = 'test';
     $type = 'im';
     $additionalProperties = false;
     $required = 'test';
     $sUT->setId($id);
     $sUT->setType($type);
     $sUT->setAdditionalProperties($additionalProperties);
     $sUT->addRequired($required);
     $this->assertEquals($id, $sUT->getId());
     $this->assertEquals($type, $sUT->getType());
     $this->assertEquals($additionalProperties, $sUT->hasAdditionalProperties());
     $this->assertEquals(array($required), $sUT->getRequired());
 }
 /**
  * Similar to determineProperty but with a variation  
  * Notice that in items list there can be a collection of items - no keys here  
  * the total items represent a full definition
  * we are taking the collection of items 
  * we should take the cross section of the items and figure out base items  
  * 
  * @param array $items
  * @param string $name
  * @return Property
  */
 protected function determineItem($items, $name)
 {
     $baseUrl = $this->configKeyExists('baseUrl') ? $this->getConfigSetting('baseUrl') : null;
     $requiredDefault = $this->configKeyExists('requiredDefault') ? $this->getConfigSetting('requiredDefault') : false;
     $type = StringMapper::map($items);
     $retItem = new Item();
     $retItem->setType($type)->setName($name)->setKey($name)->setRequired($requiredDefault);
     if ($baseUrl) {
         $retItem->setId($baseUrl . '/' . $name);
     }
     // since we stacked the groups of items into their major elements
     // add ALL of them to the item listings
     if ($type == StringMapper::ARRAY_TYPE) {
         // loop through and get a list of the definitions
         // stack them together to find the greatest common
         foreach ($items as $key => $val) {
             // a collapse of each type
             $this->stackItemFields($name, $val);
         }
         // now that we have our commons lets add them to the items
         foreach ($this->itemFields[$name] as $key => $newItem) {
             $retItem->addItem($key, $this->determineItem($newItem, $key), true);
         }
     } elseif ($type == StringMapper::OBJECT_TYPE) {
         $retItem->addItem($key, $this->determineProperty($items, $key));
     }
     return $retItem;
 }