Passed
Push — master ( 34353a...479e2b )
by Jonathan
27:01 queued 23:38
created

ContainerException::entryType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
    public static function entryType(): ContainerException
17
    {
18
        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