Completed
Pull Request — develop (#126)
by Chuck
10:27 queued 08:42
created

Function_   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 92%

Importance

Changes 0
Metric Value
dl 0
loc 105
ccs 23
cts 25
cp 0.92
rs 10
c 0
b 0
f 0
wmc 10
lcom 2
cbo 3

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 3
A getArguments() 0 4 1
A addArgument() 0 4 1
A getFqsen() 0 4 1
A getName() 0 4 1
A getDocBlock() 0 4 1
A getLocation() 0 4 1
A getReturnType() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @copyright 2010-2018 Mike van Riel<[email protected]>
11
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
12
 * @link      http://phpdoc.org
13
 */
14
15
namespace phpDocumentor\Reflection\Php;
16
17
use phpDocumentor\Reflection\DocBlock;
18
use phpDocumentor\Reflection\Element;
19
use phpDocumentor\Reflection\Fqsen;
20
use phpDocumentor\Reflection\Location;
21
use phpDocumentor\Reflection\Type;
22
use phpDocumentor\Reflection\Types\Mixed_;
23
24
/**
25
 * Descriptor representing a function
26
 */
27
// @codingStandardsIgnoreStart
28
final class Function_ implements Element
29
// // @codingStandardsIgnoreEnd
30
{
31
    /**
32
     * @var Fqsen Full Qualified Structural Element Name
33
     */
34
    private $fqsen;
35
36
    /** @var Argument[] $arguments */
37
    private $arguments = [];
38
39
    /**
40
     * @var DocBlock|null
41
     */
42
    private $docBlock;
43
44
    /**
45
     * @var Location
46
     */
47
    private $location;
48
49
    /**
50
     * @var Type
51
     */
52
    private $returnType;
53
54
    /**
55
     * Initializes the object.
56
     *
57
     * @param DocBlock|null $docBlock
58
     * @param Location|null $location
59
     * @param Type|null $returnType
60
     */
61 5
    public function __construct(
62
        Fqsen $fqsen,
63
        DocBlock $docBlock = null,
64
        Location $location = null,
65
        Type $returnType = null
66
    ) {
67 5
        if ($location === null) {
68 5
            $location = new Location(-1);
69
        }
70
71 5
        if ($returnType === null) {
72 5
            $returnType = new Mixed_();
73
        }
74
75 5
        $this->fqsen = $fqsen;
76 5
        $this->docBlock = $docBlock;
77 5
        $this->location = $location;
78 5
        $this->returnType = $returnType;
79 5
    }
80
81
    /**
82
     * Returns the arguments of this function.
83
     *
84
     * @return Argument[]
85
     */
86 1
    public function getArguments(): array
87
    {
88 1
        return $this->arguments;
89
    }
90
91
    /**
92
     * Add an argument to the function.
93
     */
94 1
    public function addArgument(Argument $argument): void
95
    {
96 1
        $this->arguments[] = $argument;
97 1
    }
98
99
    /**
100
     * Returns the Fqsen of the element.
101
     */
102 1
    public function getFqsen(): Fqsen
103
    {
104 1
        return $this->fqsen;
105
    }
106
107
    /**
108
     * Returns the name of the element.
109
     */
110 1
    public function getName(): string
111
    {
112 1
        return $this->fqsen->getName();
113
    }
114
115
    /**
116
     * Returns the DocBlock of the element if available
117
     */
118 1
    public function getDocBlock(): ?DocBlock
119
    {
120 1
        return $this->docBlock;
121
    }
122
123
    public function getLocation(): Location
124
    {
125
        return $this->location;
126
    }
127
128 2
    public function getReturnType(): Type
129
    {
130 2
        return $this->returnType;
131
    }
132
}
133