Completed
Push — master ( b3d933...e7435a )
by Francesco
02:21
created

Segment::torray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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
     * @return int
63
     */
64
    public function getId()
65
    {
66
        return $this->id;
67
    }
68
69
    /**
70
     * @param int $id
71
     */
72
    public function setId($id)
73
    {
74
        $this->id = $id;
75
    }
76
77
    /**
78
     * @return boolean
79
     */
80
    public function isActive()
81
    {
82
        return $this->active;
83
    }
84
85
    /**
86
     * @param boolean $active
87
     */
88
    public function setActive($active)
89
    {
90
        $this->active = $active;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getDescription()
97
    {
98
        return $this->description;
99
    }
100
101
    /**
102
     * @param string $description
103
     */
104
    public function setDescription($description)
105
    {
106
        $this->description = $description;
107
    }
108
109
    /**
110
     * @return int
111
     */
112
    public function getMemberId()
113
    {
114
        return $this->member_id;
115
    }
116
117
    /**
118
     * @param int $memberId
119
     */
120
    public function setMemberId($memberId)
121
    {
122
        $this->member_id = $memberId;
123
    }
124
125
    /**
126
     * @return string
127
     */
128
    public function getCode()
129
    {
130
        return $this->code;
131
    }
132
133
    /**
134
     * @param string $code
135
     */
136
    public function setCode($code)
137
    {
138
        $this->code = $code;
139
    }
140
141
    /**
142
     * @return string
143
     */
144
    public function getProvider()
145
    {
146
        return $this->provider;
147
    }
148
149
    /**
150
     * @param string $provider
151
     */
152
    public function setProvider($provider)
153
    {
154
        $this->provider = $provider;
155
    }
156
157
    /**
158
     * @return float
159
     */
160
    public function getPrice()
161
    {
162
        return $this->price;
163
    }
164
165
    /**
166
     * @param float $price
167
     */
168
    public function setPrice($price)
169
    {
170
        $this->price = $price;
171
    }
172
173
    /**
174
     * @return string
175
     */
176
    public function getName()
177
    {
178
        return $this->short_name;
179
    }
180
181
    /**
182
     * @param string $name
183
     */
184
    public function setName($name)
185
    {
186
        $this->short_name = $name;
187
    }
188
189
    /**
190
     * @return int
191
     */
192
    public function getExpireMinutes()
193
    {
194
        return $this->expire_minutes;
195
    }
196
197
    /**
198
     * @param int $expireMinutes
199
     */
200
    public function setExpireMinutes($expireMinutes)
201
    {
202
        $this->expire_minutes = $expireMinutes;
203
    }
204
205
    /**
206
     * @return string
207
     */
208
    public function getCategory()
209
    {
210
        return $this->category;
211
    }
212
213
    /**
214
     * @param string $category
215
     */
216
    public function setCategory($category)
217
    {
218
        $this->category = $category;
219
    }
220
221
    /**
222
     * @return \Datetime
223
     */
224
    public function getLastActivity()
225
    {
226
        return $this->last_activity;
227
    }
228
229
    /**
230
     * @param \Datetime $lastActivity
231
     */
232
    public function setLastActivity(\Datetime $lastActivity)
233
    {
234
        $this->last_activity = $lastActivity;
235
    }
236
237
    /**
238
     * @return boolean
239
     */
240
    public function isEnableRmPiggyback()
241
    {
242
        return $this->enable_rm_piggy_back;
243
    }
244
245
    /**
246
     * @param boolean $enableRmPiggyback
247
     */
248
    public function setEnableRmPiggyback($enableRmPiggyback)
249
    {
250
        $this->enable_rm_piggy_back = $enableRmPiggyback;
251
    }
252
253
    /**
254
     * @param array $segmentArray
255
     *
256
     * @return Segment
257
     */
258
    public static function fromArray(array $segmentArray)
259
    {
260
261
        $config = new Configuration(Segment::class);
262
        $hydratorClass = $config->createFactory()->getHydratorClass();
263
        $hydrator = new $hydratorClass();
264
        $segment = new self();
265
266
        $hydrator->hydrate($segmentArray, $segment);
267
268
        return $segment;
269
    }
270
271
    /**
272
     * @return array
273
     */
274
    public function torray()
275
    {
276
277
        $config = new Configuration(Segment::class);
278
        $hydratorClass = $config->createFactory()->getHydratorClass();
279
        $hydrator = new $hydratorClass();
280
281
        return $hydrator->extract($this);
282
283
    }
284
285
}
286