Пример #1
0
 /**
  * @param EntitiesDescriptor|EntityDescriptor $item
  *
  * @return EntitiesDescriptor
  *
  * @throws \InvalidArgumentException
  */
 public function addItem($item)
 {
     if (false == $item instanceof self && false == $item instanceof EntityDescriptor) {
         throw new \InvalidArgumentException('Expected EntitiesDescriptor or EntityDescriptor');
     }
     if ($item === $this) {
         throw new \InvalidArgumentException('Circular reference detected');
     }
     if ($item instanceof self) {
         if ($item->containsItem($this)) {
             throw new \InvalidArgumentException('Circular reference detected');
         }
     }
     $this->items[] = $item;
     return $this;
 }