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.

Base::removeConfigValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Workflow library.
5
 *
6
 * @package    workflow
7
 * @author     David Molineus <[email protected]>
8
 * @copyright  2014-2017 netzmacht David Molineus
9
 * @license    LGPL 3.0 https://github.com/netzmacht/workflow
10
 * @filesource
11
 */
12
13
declare(strict_types=1);
14
15
namespace Netzmacht\Workflow\Flow;
16
17
/**
18
 * Class Configurable is the base class for each flow elements.
19
 *
20
 * @package Netzmacht\Workflow\Flow
21
 */
22
abstract class Base
23
{
24
    /**
25
     * Configuration values.
26
     *
27
     * @var array
28
     */
29
    private $config = array();
30
31
    /**
32
     * Name of the element.
33
     *
34
     * @var string
35
     */
36
    private $name;
37
38
    /**
39
     * Label of the element.
40
     *
41
     * @var string
42
     */
43
    private $label;
44
45
    /**
46
     * Construct.
47
     *
48
     * @param string $name   Name of the element.
49
     * @param string $label  Label of the element.
50
     * @param array  $config Configuration values.
51
     */
52
    public function __construct(string $name, string $label = '', array $config = array())
53
    {
54
        $this->name   = $name;
55
        $this->label  = $label ?: $name;
56
        $this->config = $config;
57
    }
58
59
    /**
60
     * Get element label.
61
     *
62
     * @return string
63
     */
64
    public function getLabel(): string
65
    {
66
        return $this->label;
67
    }
68
69
    /**
70
     * Set the label.
71
     *
72
     * @param string $label The label.
73
     *
74
     * @return $this
75
     */
76
    public function setLabel(string $label): self
77
    {
78
        $this->label = $label;
79
80
        return $this;
81
    }
82
83
    /**
84
     * Get element name.
85
     *
86
     * @return string
87
     */
88
    public function getName(): string
89
    {
90
        return $this->name;
91
    }
92
93
    /**
94
     * Set a config value.
95
     *
96
     * @param string $name  Config property name.
97
     * @param mixed  $value Config property value.
98
     *
99
     * @return $this
100
     */
101
    public function setConfigValue(string $name, $value): self
102
    {
103
        $this->config[$name] = $value;
104
105
        return $this;
106
    }
107
108
    /**
109
     * Get a config value.
110
     *
111
     * @param string $name    Config property name.
112
     * @param mixed  $default Default value which is returned if config is not set.
113
     *
114
     * @return mixed
115
     */
116
    public function getConfigValue(string $name, $default = null)
117
    {
118
        if (isset($this->config[$name])) {
119
            return $this->config[$name];
120
        }
121
122
        return $default;
123
    }
124
125
    /**
126
     * Consider if config value isset.
127
     *
128
     * @param string $name Name of the config value.
129
     *
130
     * @return bool
131
     */
132
    public function hasConfigValue(string $name): bool
133
    {
134
        return isset($this->config[$name]);
135
    }
136
137
    /**
138
     * Add multiple config properties.
139
     *
140
     * @param array $values Config values.
141
     *
142
     * @return $this
143
     */
144
    public function addConfig(array $values): self
145
    {
146
        foreach ($values as $name => $value) {
147
            $this->setConfigValue($name, $value);
148
        }
149
150
        return $this;
151
    }
152
153
    /**
154
     * Remove a config property.
155
     *
156
     * @param string $name Config property name.
157
     *
158
     * @return $this
159
     */
160
    public function removeConfigValue(string $name): self
161
    {
162
        unset($this->config[$name]);
163
164
        return $this;
165
    }
166
167
    /**
168
     * Get configuration.
169
     *
170
     * @return array
171
     */
172
    public function getConfig(): array
173
    {
174
        return $this->config;
175
    }
176
}
177