Completed
Pull Request — master (#6)
by Nick
15:48
created

Goal::setRuleIds()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
use Acquia\LiftClient\Exception\LiftSdkException;
6
use Acquia\LiftClient\Utility\Utility;
7
8
class Goal extends \ArrayObject
9
{
10
    use EntityTrait;
11
12
    /**
13
     * @param array $array
14
     */
15
    public function __construct(array $array = [])
16
    {
17
        parent::__construct($array);
18
    }
19
20
    /**
21
     * Sets the 'id' parameter.
22
     *
23
     * @param string $id
24
     *
25
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
26
     *
27
     * @return \Acquia\LiftClient\Entity\Goal
28
     */
29 View Code Duplication
    public function setId($id)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        if (!is_string($id)) {
32
            throw new LiftSdkException('Argument must be an instance of string.');
33
        }
34
        $this['id'] = $id;
35
36
        return $this;
37
    }
38
39
    /**
40
     * Gets the 'id' parameter.
41
     *
42
     * @return string The Identifier of the Goal
43
     */
44
    public function getId()
45
    {
46
        return $this->getEntityValue('id', '');
47
    }
48
49
    /**
50
     * Sets the 'name' parameter.
51
     *
52
     * @param string $name
53
     *
54
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
55
     *
56
     * @return \Acquia\LiftClient\Entity\Goal
57
     */
58 View Code Duplication
    public function setName($name)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        if (!is_string($name)) {
61
            throw new LiftSdkException('Argument must be an instance of string.');
62
        }
63
        $this['name'] = $name;
64
65
        return $this;
66
    }
67
68
    /**
69
     * Gets the 'name' parameter.
70
     *
71
     * @return string
72
     *                The Name of the Goal
73
     */
74
    public function getName()
75
    {
76
        return $this->getEntityValue('name', '');
77
    }
78
79
    /**
80
     * Sets the 'description' parameter.
81
     *
82
     * @param string $description
83
     *
84
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
85
     *
86
     * @return \Acquia\LiftClient\Entity\Goal
87
     */
88 View Code Duplication
    public function setDescription($description)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
    {
90
        if (!is_string($description)) {
91
            throw new LiftSdkException('Argument must be an instance of string.');
92
        }
93
        $this['description'] = $description;
94
95
        return $this;
96
    }
97
98
    /**
99
     * Gets the 'description' parameter.
100
     *
101
     * @return string The Description of the Goal
102
     */
103
    public function getDescription()
104
    {
105
        return $this->getEntityValue('description', '');
106
    }
107
108
    /**
109
     * Sets the 'rule_ids' parameter.
110
     *
111
     * @param array $ruleIds
112
     *
113
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
114
     *
115
     * @return \Acquia\LiftClient\Entity\Goal
116
     */
117 View Code Duplication
    public function setRuleIds(array $ruleIds)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    {
119
        if (Utility::arrayDepth($ruleIds) > 1) {
120
            throw new LiftSdkException('Rule Ids argument is more than 1 level deep.');
121
        }
122
123
        // Set only the array values to the rule_ids property.
124
        $this['rule_ids'] = array_values($ruleIds);
125
126
        return $this;
127
    }
128
129
    /**
130
     * Gets the 'rule_ids' parameter.
131
     *
132
     * @return array The Rule Identifiers
133
     */
134
    public function getRuleIds()
135
    {
136
        return $this->getEntityValue('rule_ids', array());
0 ignored issues
show
Documentation introduced by
array() is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
137
    }
138
139
    /**
140
     * Sets the 'site_ids' parameter.
141
     *
142
     * @param array $siteIds
143
     *
144
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
145
     *
146
     * @return \Acquia\LiftClient\Entity\Goal
147
     */
148 View Code Duplication
    public function setSiteIds(array $siteIds)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
149
    {
150
        if (Utility::arrayDepth($siteIds) > 1) {
151
            throw new LiftSdkException('site_ids argument is more than 1 level deep.');
152
        }
153
154
        // Set only the array values to the rule_ids property.
155
        $this['site_ids'] = array_values($siteIds);
156
157
        return $this;
158
    }
159
160
    /**
161
     * Gets the 'site_ids' parameter.
162
     *
163
     * @return array The Site Identifiers
164
     */
165
    public function getSiteIds()
166
    {
167
        return $this->getEntityValue('site_ids', array());
0 ignored issues
show
Documentation introduced by
array() is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
168
    }
169
170
    /**
171
     * Sets the 'event_names' parameter.
172
     *
173
     * @param array $eventNames
174
     *
175
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
176
     *
177
     * @return \Acquia\LiftClient\Entity\Goal
178
     */
179 View Code Duplication
    public function setEventNames(array $eventNames)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
180
    {
181
        if (Utility::arrayDepth($eventNames) > 1) {
182
            throw new LiftSdkException('Event Names argument is more than 1 level deep.');
183
        }
184
185
        // Set only the array values to the event_names property.
186
        $this['event_names'] = array_values($eventNames);
187
188
        return $this;
189
    }
190
191
    /**
192
     * Gets the 'rule_ids' parameter.
193
     *
194
     * @return array The Rule Identifiers
195
     */
196
    public function getEventNames()
197
    {
198
        return $this->getEntityValue('event_names', array());
0 ignored issues
show
Documentation introduced by
array() is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
199
    }
200
201
    /**
202
     * Sets the 'global' parameter.
203
     *
204
     * @param bool $global
205
     *
206
     * @return \Acquia\LiftClient\Entity\Slot
207
     */
208
    public function setGlobal($global)
209
    {
210
        $this['global'] = $global;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Gets the 'global' parameter.
217
     *
218
     * @return bool
219
     */
220
    public function getGlobal()
221
    {
222
        return $this->getEntityValue('global', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
223
    }
224
225
    /**
226
     * Sets the 'value' parameter.
227
     *
228
     * @param float|int $value
229
     *
230
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
231
     *
232
     * @return \Acquia\LiftClient\Entity\Goal
233
     */
234
    public function setValue($value)
235
    {
236
        if (!is_float($value) && !is_int($value)) {
237
            throw new LiftSdkException('Argument must be an instance of float or int.');
238
        }
239
        $this['value'] = $value;
240
241
        return $this;
242
    }
243
244
    /**
245
     * Gets the 'value' parameter.
246
     *
247
     * @return float
248
     */
249
    public function getValue()
250
    {
251
        return $this->getEntityValue('value', '');
252
    }
253
}
254