ParameterNotFoundException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 3
1
<?php
2
3
namespace Aidphp\Di;
4
5
use InvalidArgumentException;
6
use Psr\Container\NotFoundExceptionInterface;
7
use ReflectionParameter;
8
use Throwable;
9
10
class ParameterNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
11
{
12 2
    public function __construct(ReflectionParameter $param, Throwable $previous = null)
13
    {
14 2
        $msg = 'Unable to resolve the parameter ' . ($param->getPosition() + 1) . ' named $' . $param->name . ($param->hasType() ? ' of type ' . $param->getType() : '') .
15 2
        ' in ' . (null !== ($class = $param->getDeclaringClass()) ? $class->name . '::' : '') . $param->getDeclaringFunction()->name . '()';
16
17 2
        parent::__construct($msg, 0, $previous);
18
    }
19
}