ContainerAwareTrait.php
<?php declare(strict_types=1);
namespace Automattic\WooCommerce\Vendor\League\Container;
use Automattic\WooCommerce\Vendor\League\Container\Exception\ContainerException;
use Automattic\WooCommerce\Vendor\Psr\Container\ContainerInterface;
trait ContainerAwareTrait
{
protected $container;
protected $leagueContainer;
public function setContainer(ContainerInterface $container) : ContainerAwareInterface
{
$this->container = $container;
return $this;
}
public function getContainer() : ContainerInterface
{
if ($this->container instanceof ContainerInterface) {
return $this->container;
}
throw new ContainerException('No container implementation has been set.');
}
public function setLeagueContainer(Container $container) : ContainerAwareInterface
{
$this->container = $container;
$this->leagueContainer = $container;
return $this;
}
public function getLeagueContainer() : Container
{
if ($this->leagueContainer instanceof Container) {
return $this->leagueContainer;
}
throw new ContainerException('No container implementation has been set.');
}
}