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

Argument::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
/**
18
 * Descriptor representing a single Argument of a method or function.
19
 */
20
final class Argument
21
{
22
    /**
23
     * @var string name of the Argument
24
     */
25
    private $name = null;
26
27
    /** @var string[] $type an array of normalized types that should be in this Argument */
28
    private $types = [];
29
30
    /** @var string|null $default the default value for an argument or null if none is provided */
31
    private $default = null;
32
33
    /** @var bool $byReference whether the argument passes the parameter by reference instead of by value */
34
    private $byReference = false;
35
36
    /** @var boolean Determines if this Argument represents a variadic argument */
37
    private $isVariadic = false;
38
39
    /**
40
     * Initializes the object.
41
     */
42 4
    public function __construct(string $name, string $default = null, bool $byReference = false, bool $isVariadic = false)
43
    {
44 4
        $this->name = $name;
45 4
        $this->default = $default;
46 4
        $this->byReference = $byReference;
47 4
        $this->isVariadic = $isVariadic;
48 4
    }
49
50
    /**
51
     * Returns the name of this argument.
52
     */
53 1
    public function getName(): string
54
    {
55 1
        return $this->name;
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61 1
    public function getTypes(): array
62
    {
63 1
        return $this->types;
64
    }
65
66
    /**
67
     * Add a type.
68
     * @param mixed $type
69
     */
70 1
    public function addType($type): void
71
    {
72 1
        $this->types[] = $type;
73 1
    }
74
75
    /**
76
     * {@inheritDoc}
77
     */
78 1
    public function getDefault(): ?string
79
    {
80 1
        return $this->default;
81
    }
82
83
    /**
84
     * {@inheritDoc}
85
     */
86 1
    public function isByReference(): bool
87
    {
88 1
        return $this->byReference;
89
    }
90
91
    /**
92
     * Returns whether this argument represents a variadic argument.
93
     */
94 1
    public function isVariadic(): bool
95
    {
96 1
        return $this->isVariadic;
97
    }
98
}
99