Completed
Pull Request — master (#237)
by Kamil
02:23
created

ArgumentNode   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 2 Features 1
Metric Value
wmc 13
c 2
b 2
f 1
lcom 1
cbo 0
dl 0
loc 73
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getTypeHint() 0 4 1
A setTypeHint() 0 4 1
A hasDefault() 0 4 2
A getDefault() 0 4 1
A setDefault() 0 5 1
A isOptional() 0 4 1
A setAsPassedByReference() 0 4 1
A isPassedByReference() 0 4 1
A setAsVariadic() 0 4 1
A isVariadic() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\Doubler\Generator\Node;
13
14
/**
15
 * Argument node.
16
 *
17
 * @author Konstantin Kudryashov <[email protected]>
18
 */
19
class ArgumentNode
20
{
21
    private $name;
22
    private $typeHint;
23
    private $default;
24
    private $optional    = false;
25
    private $byReference = false;
26
    private $isVariadic  = false;
27
28
    /**
29
     * @param string $name
30
     */
31
    public function __construct($name)
32
    {
33
        $this->name = $name;
34
    }
35
36
    public function getName()
37
    {
38
        return $this->name;
39
    }
40
41
    public function getTypeHint()
42
    {
43
        return $this->typeHint;
44
    }
45
46
    public function setTypeHint($typeHint = null)
47
    {
48
        $this->typeHint = $typeHint;
49
    }
50
51
    public function hasDefault()
52
    {
53
        return $this->isOptional() && !$this->isVariadic();
54
    }
55
56
    public function getDefault()
57
    {
58
        return $this->default;
59
    }
60
61
    public function setDefault($default = null)
62
    {
63
        $this->optional = true;
64
        $this->default  = $default;
65
    }
66
67
    public function isOptional()
68
    {
69
        return $this->optional;
70
    }
71
72
    public function setAsPassedByReference($byReference = true)
73
    {
74
        $this->byReference = $byReference;
75
    }
76
77
    public function isPassedByReference()
78
    {
79
        return $this->byReference;
80
    }
81
82
    public function setAsVariadic($isVariadic = true)
83
    {
84
        $this->isVariadic = $isVariadic;
85
    }
86
87
    public function isVariadic()
88
    {
89
        return $this->isVariadic;
90
    }
91
}
92