/** * Construction of a collection * * @param array|string $items_collection The array of the collection content (optional) * @throws \InvalidArgumentException if the collection argument is not an array */ public function __construct($items_collection = array()) { if (empty($items_collection)) { throw new \InvalidArgumentException(sprintf('Creation of a "%s" instance with no items collection is not allowed!', __CLASS__)); } if (!is_array($items_collection)) { $items_collection = array($items_collection); } parent::__construct($items_collection); }
/** * Unset a service if it is not protected * * @param string $name * @return mixed * @throws \ErrorException */ public function unsetService($name) { if ($this->hasService($name)) { if (!$this->isProtected($name)) { if ($this->hasProvider($name)) { $data = $this->getProvider($name); if (is_object($data) && CodeHelper::implementsInterface($data, 'ServiceContainer\\ServiceProviderInterface')) { $data->terminate($this); } } $this->_services->offsetUnset($name); } else { throw new ErrorException(sprintf('Cannot unset protected service "%s"!', $name)); } } return $this; }