Completed
Push — master ( fab006...1c4cac )
by Miloš
01:47
created

InvalidDefinitionException::create()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 9
cp 0
crap 6
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Laganica\Di\Exception;
4
5
use Closure;
6
use Laganica\Di\Definition\DefinitionInterface;
7
use Psr\Container\NotFoundExceptionInterface;
8
9
/**
10
 * Class InvalidDefinitionException
11
 *
12
 * @package Laganica\Di\Exception
13
 */
14
class InvalidDefinitionException extends ContainerException implements NotFoundExceptionInterface
15
{
16
    /**
17
     * @param $definition
18
     *
19
     * @return self
20
     */
21
    public static function create($definition): self
22
    {
23
        return new self(vsprintf('Argument $definition must be either %s, %s or %s, %s given', [
24
            DefinitionInterface::class,
25
            Closure::class,
26
            'string',
27
            get_class($definition) ?: gettype($definition)
28
        ]));
29
    }
30
}
31