Completed
Push — master ( 0fb048...b3d933 )
by Francesco
02:12
created

Segment::fromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
namespace Audiens\AppnexusClient\entity;
4
5
use GeneratedHydrator\Configuration;
6
7
/**
8
 * Class Segment
9
 */
10
class Segment
11
{
12
13
    /** @var  int */
14
    protected $id;
15
16
    /** @var  bool */
17
    protected $active = true;
18
19
    /** @var  string */
20
    protected $description;
21
22
    /** @var  int */
23
    protected $member_id;
24
25
    /** @var  string */
26
    protected $code;
27
28
    /** @var  string */
29
    protected $provider;
30
31
    /** @var  float */
32
    protected $price;
33
34
    /** @var  string */
35
    protected $short_name;
36
37
    /** @var  int */
38
    protected $expire_minutes;
39
40
    /** @var  string */
41
    protected $category;
42
43
    /** @var  \Datetime */
44
    protected $last_activity;
45
46
    /** @var  bool */
47
    protected $enable_rm_piggy_back;
48
49
    /**
50
     * Segment constructor
51
     */
52
    public function __construct()
53
    {
54
        $this->active = true;
55
        $this->last_activity = new \DateTime();
56
        $this->price = 0.0;
57
        $this->provider = 'base-provider';
58
        $this->expire_minutes = 2147483647;
59
    }
60
61
62
    /**
63
     * @return int
64
     */
65
    public function getId()
66
    {
67
        return $this->id;
68
    }
69
70
    /**
71
     * @param int $id
72
     */
73
    public function setId($id)
74
    {
75
        $this->id = $id;
76
    }
77
78
    /**
79
     * @return boolean
80
     */
81
    public function isActive()
82
    {
83
        return $this->active;
84
    }
85
86
    /**
87
     * @param boolean $active
88
     */
89
    public function setActive($active)
90
    {
91
        $this->active = $active;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getDescription()
98
    {
99
        return $this->description;
100
    }
101
102
    /**
103
     * @param string $description
104
     */
105
    public function setDescription($description)
106
    {
107
        $this->description = $description;
108
    }
109
110
    /**
111
     * @return int
112
     */
113
    public function getMemberId()
114
    {
115
        return $this->member_id;
116
    }
117
118
    /**
119
     * @param int $memberId
120
     */
121
    public function setMemberId($memberId)
122
    {
123
        $this->member_id = $memberId;
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    public function getCode()
130
    {
131
        return $this->code;
132
    }
133
134
    /**
135
     * @param string $code
136
     */
137
    public function setCode($code)
138
    {
139
        $this->code = $code;
140
    }
141
142
    /**
143
     * @return string
144
     */
145
    public function getProvider()
146
    {
147
        return $this->provider;
148
    }
149
150
    /**
151
     * @param string $provider
152
     */
153
    public function setProvider($provider)
154
    {
155
        $this->provider = $provider;
156
    }
157
158
    /**
159
     * @return float
160
     */
161
    public function getPrice()
162
    {
163
        return $this->price;
164
    }
165
166
    /**
167
     * @param float $price
168
     */
169
    public function setPrice($price)
170
    {
171
        $this->price = $price;
172
    }
173
174
    /**
175
     * @return string
176
     */
177
    public function getName()
178
    {
179
        return $this->short_name;
180
    }
181
182
    /**
183
     * @param string $name
184
     */
185
    public function setName($name)
186
    {
187
        $this->short_name = $name;
188
    }
189
190
    /**
191
     * @return int
192
     */
193
    public function getExpireMinutes()
194
    {
195
        return $this->expire_minutes;
196
    }
197
198
    /**
199
     * @param int $expireMinutes
200
     */
201
    public function setExpireMinutes($expireMinutes)
202
    {
203
        $this->expire_minutes = $expireMinutes;
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function getCategory()
210
    {
211
        return $this->category;
212
    }
213
214
    /**
215
     * @param string $category
216
     */
217
    public function setCategory($category)
218
    {
219
        $this->category = $category;
220
    }
221
222
    /**
223
     * @return \Datetime
224
     */
225
    public function getLastActivity()
226
    {
227
        return $this->last_activity;
228
    }
229
230
    /**
231
     * @param \Datetime $lastActivity
232
     */
233
    public function setLastActivity(\Datetime $lastActivity)
234
    {
235
        $this->last_activity = $lastActivity;
236
    }
237
238
    /**
239
     * @return boolean
240
     */
241
    public function isEnableRmPiggyback()
242
    {
243
        return $this->enable_rm_piggy_back;
244
    }
245
246
    /**
247
     * @param boolean $enableRmPiggyback
248
     */
249
    public function setEnableRmPiggyback($enableRmPiggyback)
250
    {
251
        $this->enable_rm_piggy_back = $enableRmPiggyback;
252
    }
253
254
    /**
255
     * @param array $segmentArray
256
     *
257
     * @return Segment
258
     */
259
    public static function fromArray(array $segmentArray)
260
    {
261
262
        $config = new Configuration(Segment::class);
263
        $hydratorClass = $config->createFactory()->getHydratorClass();
264
        $hydrator = new $hydratorClass();
265
        $segment = new self();
266
267
        $hydrator->hydrate($segmentArray, $segment);
268
269
        return $segment;
270
    }
271
272
}
273
274