Argument   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 71
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getName() 0 4 1
A getType() 0 4 1
A getDefault() 0 4 1
A isByReference() 0 4 1
A isVariadic() 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\Type;
18
use phpDocumentor\Reflection\Types\Mixed_;
19
20
/**
21
 * Descriptor representing a single Argument of a method or function.
22
 */
23
final class Argument
24
{
25
    /**
26
     * @var string name of the Argument
27
     */
28
    private $name;
29
30
    /**
31
     * @var Type a normalized type that should be in this Argument
32
     */
33
    private $type;
34
35
    /**
36
     * @var string|null the default value for an argument or null if none is provided
37
     */
38
    private $default;
39
40
    /**
41
     * @var bool whether the argument passes the parameter by reference instead of by value
42
     */
43
    private $byReference;
44
45
    /**
46
     * @var boolean Determines if this Argument represents a variadic argument
47
     */
48
    private $isVariadic;
49
50
    /**
51
     * Initializes the object.
52
     */
53 4
    public function __construct(string $name, ?Type $type = null, ?string $default = null, bool $byReference = false, bool $isVariadic = false)
54
    {
55 4
        $this->name = $name;
56 4
        $this->default = $default;
57 4
        $this->byReference = $byReference;
58 4
        $this->isVariadic = $isVariadic;
59 4
        if ($type === null) {
60 4
            $type = new Mixed_();
61
        }
62
63 4
        $this->type = $type;
64 4
    }
65
66
    /**
67
     * Returns the name of this argument.
68
     */
69 1
    public function getName(): string
70
    {
71 1
        return $this->name;
72
    }
73
74 1
    public function getType(): ?Type
75
    {
76 1
        return $this->type;
77
    }
78
79 1
    public function getDefault(): ?string
80
    {
81 1
        return $this->default;
82
    }
83
84 1
    public function isByReference(): bool
85
    {
86 1
        return $this->byReference;
87
    }
88
89 1
    public function isVariadic(): bool
90
    {
91 1
        return $this->isVariadic;
92
    }
93
}
94