Passed
Pull Request — master (#129)
by Sergei
02:39
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 8
c 1
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Factory\Exception;
6
7
use ReflectionParameter;
8
9
final class NotDetermineDefaultValueOfPhpInternalException extends NotInstantiableException
10
{
11 1
    public function __construct(ReflectionParameter $parameter)
12
    {
13 1
        parent::__construct(
14 1
            sprintf(
15
                'Can not determine default value of parameter "%s" when instantinate "%s" ' .
16 1
                'because it is PHP internal. Please specify argument explicitly.',
17 1
                $parameter->getName(),
18 1
                $this->getCallable($parameter),
19
            )
20
        );
21 1
    }
22
23 1
    private function getCallable(ReflectionParameter $parameter): string
24
    {
25 1
        $callable = [];
26
27 1
        $class = $parameter->getDeclaringClass();
28 1
        if ($class !== null) {
29 1
            $callable[] = $class->getName();
30
        }
31 1
        $callable[] = $parameter->getDeclaringFunction()->getName() . '()';
32
33 1
        return implode('::', $callable);
34
    }
35
}
36