Completed
Push — master ( cf321a...f177e6 )
by Thibaud
07:25
created

OrderElement::getRecordId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    /***
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
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->databox_id;
89
    }
90
91
    /**
92
     * @return int
93
     */
94
    public function getRecordId()
95
    {
96
        return (int) $this->source->record_id;
97
    }
98
99
    /**
100
     * @return int
101
     */
102
    public function getIndex()
103
    {
104
        return (int) $this->source->index;
105
    }
106
}
107