Spade
Mini Shell
<?php
/**
* @package OSL
* @subpackage Container
*
* @copyright Copyright (C) 2016 Ossolution Team, Inc. All rights
reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace OSL\Container;
/**
* Defines the trait for a Container Aware Class.
*
* @since 1.0
*
*/
trait ContainerAwareTrait
{
/**
* DI Container
*
* @var Container
* @since 1.0
*/
protected $container;
/**
* Get the DI container.
*
* @return Container
*
* @since 1.0
*
* @throws \UnexpectedValueException May be thrown if the container has
not been set.
*/
public function getContainer()
{
if ($this->container)
{
return $this->container;
}
throw new \UnexpectedValueException('Container not set in ' .
__CLASS__);
}
/**
* Set the DI container.
*
* @param Container $container The DI container.
*
* @return mixed Returns itself to support chaining.
*
* @since 1.0
*/
public function setContainer(Container $container)
{
$this->container = $container;
return $this;
}
}