Function_::getDocBlock()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 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
    /**
37
     * @var Argument[]
38
     */
39
    private $arguments = [];
40
41
    /**
42
     * @var DocBlock|null
43
     */
44
    private $docBlock;
45
46
    /**
47
     * @var Location
48
     */
49
    private $location;
50
51
    /**
52
     * @var Type
53
     */
54
    private $returnType;
55
56
    /**
57
     * Initializes the object.
58
     *
59
     * @param DocBlock|null $docBlock
60
     * @param Location|null $location
61
     * @param Type|null $returnType
62
     */
63 5
    public function __construct(
64
        Fqsen $fqsen,
65
        ?DocBlock $docBlock = null,
66
        ?Location $location = null,
67
        ?Type $returnType = null
68
    ) {
69 5
        if ($location === null) {
70 5
            $location = new Location(-1);
71
        }
72
73 5
        if ($returnType === null) {
74 5
            $returnType = new Mixed_();
75
        }
76
77 5
        $this->fqsen = $fqsen;
78 5
        $this->docBlock = $docBlock;
79 5
        $this->location = $location;
80 5
        $this->returnType = $returnType;
81 5
    }
82
83
    /**
84
     * Returns the arguments of this function.
85
     *
86
     * @return Argument[]
87
     */
88 1
    public function getArguments(): array
89
    {
90 1
        return $this->arguments;
91
    }
92
93
    /**
94
     * Add an argument to the function.
95
     */
96 1
    public function addArgument(Argument $argument): void
97
    {
98 1
        $this->arguments[] = $argument;
99 1
    }
100
101
    /**
102
     * Returns the Fqsen of the element.
103
     */
104 1
    public function getFqsen(): Fqsen
105
    {
106 1
        return $this->fqsen;
107
    }
108
109
    /**
110
     * Returns the name of the element.
111
     */
112 1
    public function getName(): string
113
    {
114 1
        return $this->fqsen->getName();
115
    }
116
117
    /**
118
     * Returns the DocBlock of the element if available
119
     */
120 1
    public function getDocBlock(): ?DocBlock
121
    {
122 1
        return $this->docBlock;
123
    }
124
125
    public function getLocation(): Location
126
    {
127
        return $this->location;
128
    }
129
130 2
    public function getReturnType(): Type
131
    {
132 2
        return $this->returnType;
133
    }
134
}
135