Passed
Push — master ( e05046...fea23e )
by Jonathan
03:48
created

ContainerException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findType() 0 3 2
A shareOnMake() 0 3 1
A entryType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gravatalonga\Container;
6
7
use Exception;
8
use Psr\Container\ContainerExceptionInterface;
9
use ReflectionNamedType;
10
11
final class ContainerException extends Exception implements ContainerExceptionInterface
12
{
13
    /**
14
     * @return ContainerException
15
     */
16 3
    public static function entryType(): ContainerException
17
    {
18 3
        return new self(sprintf('Entry type must be string'));
19
    }
20
21
    /**
22
     * @param ReflectionNamedType|null $type
23
     *
24
     * @return ContainerException
25
     */
26 6
    public static function findType(?ReflectionNamedType $type): ContainerException
27
    {
28 6
        return new self(sprintf('Unable to find type hint (%s)', ($type ? $type->getName() : '')));
29
    }
30
31
    /**
32
     * @param string $id
33
     *
34
     * @return ContainerException
35
     */
36 3
    public static function shareOnMake(string $id): ContainerException
37
    {
38 3
        return new self(sprintf('Entry is shared and cannot be called on make: %s', $id));
39
    }
40
}
41