Completed
Push — master ( 5decb7...aee104 )
by Thibaud
14:37 queued 11:26
created

FeedEntryItem   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 88.24%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 8
c 7
b 0
f 0
lcom 1
cbo 1
dl 0
loc 65
ccs 15
cts 17
cp 0.8824
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fromList() 0 10 2
A fromValue() 0 4 1
A __construct() 0 4 1
A getRawData() 0 4 1
A getId() 0 4 1
A getRecord() 0 4 2
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