BadDeclarationException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Exception;
6
7
use Exception;
8
9
class BadDeclarationException extends Exception
10
{
11
    /**
12
     * @param non-empty-string $parameter
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
13
     * @param class-string $class
14
     */
15 24
    public function __construct(string $parameter, string $class, mixed $argument)
16
    {
17 24
        $type = \is_object($argument)
18 9
            ? 'Instance of ' . \get_class($argument)
19 15
            : \ucfirst(\get_debug_type($argument));
20 24
        parent::__construct(\sprintf(
21 24
            '%s should be instance of %s or its declaration. %s was received instead.',
22 24
            $parameter,
23 24
            $class,
24 24
            $type
25 24
        ));
26
    }
27
}
28