ArgumentException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 51
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getParameter() 0 4 1
A getContext() 0 4 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\Core\Exceptions\Container;
10
11
/**
12
 * Unable to resolve argument value.
13
 */
14
class ArgumentException extends AutowireException
15
{
16
    /**
17
     * Parameter caused error.
18
     *
19
     * @var \ReflectionParameter
20
     */
21
    protected $parameter = null;
22
23
    /**
24
     * Context method or constructor or function.
25
     *
26
     * @var \ReflectionFunctionAbstract
27
     */
28
    protected $context = null;
29
30
    /**
31
     * @param \ReflectionParameter        $parameter
32
     * @param \ReflectionFunctionAbstract $context
33
     */
34 7
    public function __construct(
35
        \ReflectionParameter $parameter,
36
        \ReflectionFunctionAbstract $context
37
    ) {
38 7
        $this->parameter = $parameter;
39 7
        $this->context = $context;
40
41 7
        $name = $context->getName();
42 7
        if ($context instanceof \ReflectionMethod) {
43 7
            $name = $context->class . '::' . $name;
44
        }
45
46 7
        parent::__construct("Unable to resolve '{$parameter->name}' argument in '{$name}'");
47 7
    }
48
49
    /**
50
     * @return \ReflectionParameter
51
     */
52 1
    public function getParameter()
53
    {
54 1
        return $this->parameter;
55
    }
56
57
    /**
58
     * @return \ReflectionFunctionAbstract
59
     */
60 1
    public function getContext()
61
    {
62 1
        return $this->context;
63
    }
64
}
65