Completed
Pull Request — master (#73)
by Thibaud
11:28
created

FeedEntryItem::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of Phraseanet 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\Entity;
13
14
class FeedEntryItem
15
{
16
17 3
    public static function fromList(array $values)
18
    {
19 3
        $items = array();
20
21 3
        foreach ($values as $value) {
22 3
            $items[$value->item_id] = self::fromValue($value);
23 3
        }
24
25 3
        return $items;
26
    }
27
28 3
    public static function fromValue(\stdClass $value)
29
    {
30 3
        return new self($value);
31
    }
32
33
    /**
34
     * @var \stdClass
35
     */
36
    protected $source;
37
38
    /**
39
     * @var Record|null
40
     */
41
    protected $record;
42
43
    /**
44
     * @param \stdClass $source
45
     */
46 3
    public function __construct(\stdClass $source)
47
    {
48 3
        $this->source = $source;
49 3
    }
50
51
    /**
52
     * @return \stdClass
53
     */
54
    public function getRawData()
55
    {
56
        return $this->source;
57
    }
58
59
    /**
60
     * Get the item id
61
     *
62
     * @return integer
63
     */
64 3
    public function getId()
65
    {
66 3
        return $this->source->item_id;
67
    }
68
69
    /**
70
     * Get the associated record object
71
     *
72
     * @return Record
73
     */
74 3
    public function getRecord()
75
    {
76 3
        return $this->record ?: $this->record = Record::fromValue($this->source->record);
77
    }
78
}
79