Completed
Push — master ( 7b6a9e...621ea2 )
by Nick
15:23
created

Goal::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 The Name of the Goal
72
     */
73
    public function getName()
74
    {
75
        return $this->getEntityValue('name', '');
76
    }
77
78
    /**
79
     * Sets the 'description' parameter.
80
     *
81
     * @param string $description
82
     *
83
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
84
     *
85
     * @return \Acquia\LiftClient\Entity\Goal
86
     */
87 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...
88
    {
89
        if (!is_string($description)) {
90
            throw new LiftSdkException('Argument must be an instance of string.');
91
        }
92
        $this['description'] = $description;
93
94
        return $this;
95
    }
96
97
    /**
98
     * Gets the 'description' parameter.
99
     *
100
     * @return string The Description of the Goal
101
     */
102
    public function getDescription()
103
    {
104
        return $this->getEntityValue('description', '');
105
    }
106
107
    /**
108
     * Sets the 'rule_ids' parameter.
109
     *
110
     * @param array $ruleIds
111
     *
112
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
113
     *
114
     * @return \Acquia\LiftClient\Entity\Goal
115
     */
116 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...
117
    {
118
        if (Utility::arrayDepth($ruleIds) > 1) {
119
            throw new LiftSdkException('Rule Ids argument is more than 1 level deep.');
120
        }
121
122
        // Set only the array values to the rule_ids property.
123
        $this['rule_ids'] = array_values($ruleIds);
124
125
        return $this;
126
    }
127
128
    /**
129
     * Gets the 'rule_ids' parameter.
130
     *
131
     * @return array The Rule Identifiers
132
     */
133
    public function getRuleIds()
134
    {
135
        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...
136
    }
137
138
    /**
139
     * Sets the 'site_ids' parameter.
140
     *
141
     * @param array $siteIds
142
     *
143
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
144
     *
145
     * @return \Acquia\LiftClient\Entity\Goal
146
     */
147 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...
148
    {
149
        if (Utility::arrayDepth($siteIds) > 1) {
150
            throw new LiftSdkException('site_ids argument is more than 1 level deep.');
151
        }
152
153
        // Set only the array values to the site_ids property.
154
        $this['site_ids'] = array_values($siteIds);
155
156
        return $this;
157
    }
158
159
    /**
160
     * Gets the 'site_ids' parameter.
161
     *
162
     * @return array The Site Identifiers
163
     */
164
    public function getSiteIds()
165
    {
166
        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...
167
    }
168
169
    /**
170
     * Sets the 'event_names' parameter.
171
     *
172
     * @param array $eventNames
173
     *
174
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
175
     *
176
     * @return \Acquia\LiftClient\Entity\Goal
177
     */
178 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...
179
    {
180
        if (Utility::arrayDepth($eventNames) > 1) {
181
            throw new LiftSdkException('Event Names argument is more than 1 level deep.');
182
        }
183
184
        // Set only the array values to the event_names property.
185
        $this['event_names'] = array_values($eventNames);
186
187
        return $this;
188
    }
189
190
    /**
191
     * Gets the 'rule_ids' parameter.
192
     *
193
     * @return array The Rule Identifiers
194
     */
195
    public function getEventNames()
196
    {
197
        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...
198
    }
199
200
    /**
201
     * Sets the 'global' parameter.
202
     *
203
     * @param bool $global
204
     *
205
     * @return \Acquia\LiftClient\Entity\Slot
206
     */
207
    public function setGlobal($global)
208
    {
209
        $this['global'] = $global;
210
211
        return $this;
212
    }
213
214
    /**
215
     * Gets the 'global' parameter.
216
     *
217
     * @return bool
218
     */
219
    public function getGlobal()
220
    {
221
        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...
222
    }
223
224
    /**
225
     * Sets the 'value' parameter.
226
     *
227
     * @param float|int $value
228
     *
229
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
230
     *
231
     * @return \Acquia\LiftClient\Entity\Goal
232
     */
233
    public function setValue($value)
234
    {
235
        if (!is_float($value) && !is_int($value)) {
236
            throw new LiftSdkException('Argument must be an instance of float or int.');
237
        }
238
        $this['value'] = $value;
239
240
        return $this;
241
    }
242
243
    /**
244
     * Gets the 'value' parameter.
245
     *
246
     * @return float
247
     */
248
    public function getValue()
249
    {
250
        return $this->getEntityValue('value', '');
251
    }
252
}
253