| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * Created by PhpStorm.
- * User: lcdee
- * Date: 31.05.2017
- * Time: 12:57
- */
- namespace AlexLcDee\RegistryContainer;
- class CategoriesContainer
- {
- /**
- * @var ItemsContainer[]
- */
- private $data = [];
- /**
- * Add new category in container
- * @param string $key
- * @param ItemsContainer $value
- */
- public function add(string $key, ItemsContainer $value)
- {
- $this->data[$key] = $value;
- }
- /**
- * Check if container has category
- * @param string $key
- * @return bool
- */
- public function has(string $key)
- {
- return isset($this->data[$key]);
- }
- /**
- * Get category from container
- * @param string $key
- * @return ItemsContainer
- * @throws RegistryException
- */
- public function get(string $key)
- {
- if(!$this->has($key)) {
- throw new RegistryException('Category not found in registry of shown items');
- }
- return $this->data[$key];
- }
- }
|