BadDeclarationException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Provider\Exception;
6
7
class BadDeclarationException extends \Exception
8
{
9
    /**
10
     * @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...
11
     * @param class-string $class
12
     */
13 8
    public function __construct(string $parameter, string $class, mixed $argument)
14
    {
15 8
        $type = \is_object($argument)
16 3
            ? 'Instance of ' . \get_class($argument)
17 5
            : \ucfirst(\get_debug_type($argument));
18 8
        parent::__construct(\sprintf(
19 8
            '%s should be instance of %s or its declaration. %s was received instead.',
20 8
            $parameter,
21 8
            $class,
22 8
            $type
23 8
        ));
24
    }
25
}
26