ExtensionException::invalidClass()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace AlexMasterov\EquipTwig\Exception;
5
6
use AlexMasterov\EquipTwig\Exception\ExceptionInterface;
7
use InvalidArgumentException;
8
use Twig_ExtensionInterface;
9
10
class ExtensionException extends InvalidArgumentException implements ExceptionInterface
11
{
12
    /**
13
     * @param string|object $spec
14
     */
15 2
    public static function invalidClass($spec): self
16
    {
17 2
        if (is_object($spec)) {
18 2
            $spec = get_class($spec);
19
        }
20
21 2
        return new static(sprintf(
22 2
            'Twig extension `%s` must implement `%s`',
23
            $spec,
24 2
            Twig_ExtensionInterface::class
25
        ));
26
    }
27
}
28