GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Parameter::setHasDefaultValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Naneau\FileGen\Parameter;
3
4
/**
5
 * A single parameter
6
 */
7
class Parameter
8
{
9
    /**
10
     * Name of the parameter
11
     *
12
     * @var string
13
     **/
14
    private $name;
15
16
    /**
17
     * Human readable description
18
     *
19
     * @var string
20
     **/
21
    private $description;
22
23
    /**
24
     * The default value
25
     *
26
     * @var mixed
27
     **/
28
    private $defaultValue;
29
30
    /**
31
     * Is there a default value?
32
     *
33
     * This is checked outside of the $defaultValue property, as `null` is a
34
     * valid default value
35
     *
36
     * @var bool
37
     **/
38
    private $hasDefaultValue = false;
39
40
    /**
41
     * Constructor
42
     *
43
     * @param  string $name        name of the parameter
44
     * @param  string $description (optional) human readable description
45
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
46
     **/
47
    public function __construct($name, $description = null)
48
    {
49
        $this->setName($name);
50
51
        // Set the description, or use the name as a fallback description if none given
52
        if ($description !== null) {
53
            $this->setDescription($description);
54
        } else {
55
            $this->setDescription($name);
56
        }
57
    }
58
59
    /**
60
     * Get the name/key of the parameter
61
     *
62
     * @return string
63
     */
64
    public function getName()
65
    {
66
        return $this->name;
67
    }
68
69
    /**
70
     * Set the name/key of the parameter
71
     *
72
     * @param  string    $name
73
     * @return Parameter
74
     */
75
    public function setName($name)
76
    {
77
        $this->name = $name;
78
79
        return $this;
80
    }
81
82
    /**
83
     * Get the description in human readable form
84
     *
85
     * @return string
86
     */
87
    public function getDescription()
88
    {
89
        return $this->description;
90
    }
91
92
    /**
93
     * Set the description in human readable form
94
     *
95
     * @param  string    $description
96
     * @return Parameter
97
     */
98
    public function setDescription($description)
99
    {
100
        $this->description = $description;
101
102
        return $this;
103
    }
104
105
    /**
106
     * Get the default value
107
     *
108
     * @return mixed
109
     */
110
    public function getDefaultValue()
111
    {
112
        return $this->defaultValue;
113
    }
114
115
    /**
116
     * Set the default value
117
     *
118
     * @param  mixed     $defaultValue
119
     * @return Parameter
120
     */
121
    public function setDefaultValue($defaultValue)
122
    {
123
        $this->setHasDefaultValue(true);
124
125
        $this->defaultValue = $defaultValue;
126
127
        return $this;
128
    }
129
130
    /**
131
     * Does this parameter have a default value?
132
     *
133
     * @return bool
134
     **/
135
    public function hasDefaultValue()
136
    {
137
        return $this->hasDefaultValue;
138
    }
139
140
    /**
141
     * Set the default value flag
142
     *
143
     * @param  bool      $hasDefaultValue
144
     * @return Parameter
145
     **/
146
    private function setHasDefaultValue($hasDefaultValue = true)
147
    {
148
        $this->hasDefaultValue = $hasDefaultValue;
149
150
        return $this;
151
    }
152
}
153