Passed
Pull Request — master (#53)
by Alexander
23:13 queued 06:44
created

BadDeclarationException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 8
rs 10
cc 2
nc 2
nop 3
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
    public function __construct(string $parameter, string $class, $argument)
12
    {
13
        $type = is_object($argument) ? 'Instance of ' . get_class($argument) : ucfirst(gettype($argument));
14
        parent::__construct(sprintf(
15
            '%s should be instance of %s or its declaration. %s was received instead.',
16
            $parameter,
17
            $class,
18
            $type
19
        ));
20
    }
21
}
22