/** * @param Item $item * @return $this */ public function addItem(Item $item) { // Check for unique identifier if (array_key_exists($item->getItemIdentifier(), $this->items)) { throw new CriticalException('Identifier already exists'); } // Check if we can validate it if (!$item->validate()) { throw new CriticalException('Cannot validate item settings, item: ' . print_r($item->render(), true)); } // Add to store $this->items[$item->getItemIdentifier()] = $item; return $this; }