1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of phraseanet/php-sdk. |
5
|
|
|
* |
6
|
|
|
* (c) Alchemy <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace PhraseanetSDK\Orders; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class OrderElement |
16
|
|
|
* @package PhraseanetSDK\Orders |
17
|
|
|
*/ |
18
|
|
|
class OrderElement |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
const STATUS_ACCEPTED = 'accepted'; |
22
|
|
|
|
23
|
|
|
const STATUS_REJECTED = 'rejected'; |
24
|
|
|
|
25
|
|
|
/*** |
|
|
|
|
26
|
|
|
* @param \stdClass[] $values |
27
|
|
|
* @return OrderElement[] |
28
|
|
|
*/ |
29
|
|
|
public static function fromList(array $values) |
30
|
|
|
{ |
31
|
|
|
$elements = array(); |
32
|
|
|
|
33
|
|
|
foreach ($values as $key => $value) { |
34
|
|
|
$elements[$key] = self::fromValue($value); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
return $elements; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param \stdClass $value |
42
|
|
|
* @return OrderElement |
43
|
|
|
*/ |
44
|
|
|
public static function fromValue(\stdClass $value) |
45
|
|
|
{ |
46
|
|
|
return new self($value); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var \stdClass |
51
|
|
|
*/ |
52
|
|
|
private $source; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var \DateTimeInterface|null |
56
|
|
|
*/ |
57
|
|
|
private $created; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param \stdClass $source |
61
|
|
|
*/ |
62
|
|
|
public function __construct(\stdClass $source) |
63
|
|
|
{ |
64
|
|
|
$this->source = $source; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return int |
69
|
|
|
*/ |
70
|
|
|
public function getId() |
71
|
|
|
{ |
72
|
|
|
return (int) $this->source->id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return \DateTime |
77
|
|
|
*/ |
78
|
|
|
public function getCreated() |
79
|
|
|
{ |
80
|
|
|
return $this->created ?: $this->created = new \DateTime($this->source->created); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return int |
85
|
|
|
*/ |
86
|
|
|
public function getDataboxId() |
87
|
|
|
{ |
88
|
|
|
return (int) $this->source->record->databox_id; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return int |
93
|
|
|
*/ |
94
|
|
|
public function getRecordId() |
95
|
|
|
{ |
96
|
|
|
return (int) $this->source->record->record_id; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getStatus() |
100
|
|
|
{ |
101
|
|
|
return $this->source->status; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return int |
106
|
|
|
*/ |
107
|
|
|
public function getIndex() |
108
|
|
|
{ |
109
|
|
|
return (int) $this->source->index; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.