QueryServiceDefinitionNotFound   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
A __construct() 0 4 1
A getContainer() 0 3 1
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