RequiredParameter::getParameter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * @author Todd Burry <[email protected]>
4
 * @copyright 2009-2017 Vanilla Forums Inc.
5
 * @license MIT
6
 * @internal
7
 */
8
9
namespace Garden\Container;
10
11
/**
12
 * A placeholder for a required parameter.
13
 */
14
class RequiredParameter extends DefaultReference {
15
    private $parameter;
16
    private $function;
17
18
    /**
19
     * RequiredParameter constructor.
20
     *
21
     * @param \ReflectionParameter $param The required parameter.
22
     */
23 7
    public function __construct(\ReflectionParameter $param) {
24 7
        parent::__construct($param->getClass() ? $param->getClass()->name : '');
25
26 7
        $this->parameter = $param->name;
27 7
        $this->function = ($param->getDeclaringClass() ? $param->getDeclaringClass()->name.'::' : '').
28 7
            $param->getDeclaringFunction()->name.'()';
29 7
    }
30
31
32
    /**
33
     * Get the name.
34
     *
35
     * @return string Returns the name.
36
     */
37
    public function getParameter() {
38
        return $this->parameter;
39
    }
40
41
    /**
42
     * Get the function.
43
     *
44
     * @return string Returns the function.
45
     */
46
    public function getFunction() {
47
        return $this->function;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     *
53
     * @throws MissingArgumentException Always throws an exception.
54
     */
55 2
    public function resolve(Container $container, $_ = null) {
56 2
        throw new MissingArgumentException($this->parameter, $this->function);
57
    }
58
}
59