Completed
Push — master ( ecde4d...469191 )
by Todd
01:43
created

RequiredParameter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 45
ccs 8
cts 12
cp 0.6667
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A getParameter() 0 3 1
A getFunction() 0 3 1
A resolve() 0 3 1
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) {
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