QueryServiceDefinitionNotFound::getContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cushon\HealthBundle\Message\QueryFactory\ServiceContainerHealthCheck\Exception;
6
7
use Cushon\HealthBundle\Message\QueryFactory\Exception\QueryFactoryException;
8
use RuntimeException;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
10
11
final class QueryServiceDefinitionNotFound extends RuntimeException implements QueryFactoryException
12
{
13
    private ContainerInterface $container;
14
    /**
15
     * @param ContainerInterface $container
16
     * @param string $definitionName
17
     * @return static
18
     */
19
    public static function create(ContainerInterface $container, string $definitionName): self
20
    {
21
        return new self(
22
            $container,
23
            sprintf(
24
                'No service definition for "%s" was found in the container',
25
                $definitionName
26
            )
27
        );
28
    }
29
30
    /**
31
     * @param ContainerInterface $container
32
     * @param string $message
33
     */
34
    private function __construct(ContainerInterface $container, string $message)
35
    {
36
        $this->container = $container;
37
        parent::__construct($message);
38
    }
39
40
    /**
41
     * @return ContainerInterface
42
     */
43
    public function getContainer(): ContainerInterface
44
    {
45
        return $this->container;
46
    }
47
}
48