Completed
Push — master ( 11f4d7...02dbf7 )
by Todd
01:44
created

RequiredParameter::getFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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 5
    public function __construct(\ReflectionParameter $param) {
24 5
        parent::__construct($param->getClass() ? $param->getClass()->name : '');
25
26 5
        $this->parameter = $param->name;
27 5
        $this->function = ($param->getDeclaringClass() ? $param->getDeclaringClass()->name.'::' : '').
28 5
            $param->getDeclaringFunction()->name.'()';
29 5
    }
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) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $_ is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
56 2
        throw new MissingArgumentException($this->parameter, $this->function);
57
    }
58
}
59