Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
37.50% covered (danger)
37.50%
6 / 16
CRAP
43.48% covered (danger)
43.48%
10 / 23
TestContainer
0.00% covered (danger)
0.00%
0 / 1
37.50% covered (danger)
37.50%
6 / 16
92.23
43.48% covered (danger)
43.48%
10 / 23
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 compile
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 isCompiled
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getParameterBag
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getParameter
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 hasParameter
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setParameter
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 set
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 has
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 get
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 initialized
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 reset
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getServiceIds
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getRemovedIds
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 getPublicContainer
0.00% covered (danger)
0.00%
0 / 1
2.15
66.67% covered (warning)
66.67%
2 / 3
 getPrivateContainer
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Bundle\FrameworkBundle\Test;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\KernelInterface;
/**
 * @author Nicolas Grekas <p@tchwork.com>
 *
 * @internal
 */
class TestContainer extends Container
{
    private $kernel;
    private $privateServicesLocatorId;
    public function __construct(KernelInterface $kernel, string $privateServicesLocatorId)
    {
        $this->kernel = $kernel;
        $this->privateServicesLocatorId = $privateServicesLocatorId;
    }
    /**
     * {@inheritdoc}
     */
    public function compile()
    {
        $this->getPublicContainer()->compile();
    }
    /**
     * {@inheritdoc}
     */
    public function isCompiled(): bool
    {
        return $this->getPublicContainer()->isCompiled();
    }
    /**
     * {@inheritdoc}
     */
    public function getParameterBag(): ParameterBagInterface
    {
        return $this->getPublicContainer()->getParameterBag();
    }
    /**
     * {@inheritdoc}
     */
    public function getParameter(string $name)
    {
        return $this->getPublicContainer()->getParameter($name);
    }
    /**
     * {@inheritdoc}
     */
    public function hasParameter(string $name): bool
    {
        return $this->getPublicContainer()->hasParameter($name);
    }
    /**
     * {@inheritdoc}
     */
    public function setParameter(string $name, $value)
    {
        $this->getPublicContainer()->setParameter($name, $value);
    }
    /**
     * {@inheritdoc}
     */
    public function set(string $id, $service)
    {
        $this->getPublicContainer()->set($id, $service);
    }
    /**
     * {@inheritdoc}
     */
    public function has($id): bool
    {
        return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
    }
    /**
     * {@inheritdoc}
     */
    public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1): ?object
    {
        return $this->getPrivateContainer()->has($id) ? $this->getPrivateContainer()->get($id) : $this->getPublicContainer()->get($id, $invalidBehavior);
    }
    /**
     * {@inheritdoc}
     */
    public function initialized(string $id): bool
    {
        return $this->getPublicContainer()->initialized($id);
    }
    /**
     * {@inheritdoc}
     */
    public function reset()
    {
        // ignore the call
    }
    /**
     * {@inheritdoc}
     */
    public function getServiceIds(): array
    {
        return $this->getPublicContainer()->getServiceIds();
    }
    /**
     * {@inheritdoc}
     */
    public function getRemovedIds(): array
    {
        return $this->getPublicContainer()->getRemovedIds();
    }
    private function getPublicContainer(): Container
    {
        if (null === $container = $this->kernel->getContainer()) {
            throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?');
        }
        return $container;
    }
    private function getPrivateContainer(): ContainerInterface
    {
        return $this->getPublicContainer()->get($this->privateServicesLocatorId);
    }
}