UnresolvableArgumentException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromParameter() 0 9 1
A getFunctionName() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the rybakit/arguments-resolver package.
7
 *
8
 * (c) Eugene Leonovich <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace ArgumentsResolver;
15
16
class UnresolvableArgumentException extends \InvalidArgumentException
17
{
18 7
    public static function fromParameter(\ReflectionParameter $parameter) : self
19
    {
20 7
        return new self(\sprintf(
21 7
            'Unable to resolve argument $%s (#%d) of %s.',
22 7
            $parameter->name,
23 7
            $parameter->getPosition(),
24 7
            self::getFunctionName($parameter->getDeclaringFunction())
25
        ));
26
    }
27
28 7
    private static function getFunctionName(\ReflectionFunctionAbstract $reflection) : string
29
    {
30 7
        $name = $reflection->name.'()';
31
32 7
        if ($reflection instanceof \ReflectionMethod) {
33 6
            $name = $reflection->getDeclaringClass()->name.'::'.$name;
34
        }
35
36 7
        return $name;
37
    }
38
}
39