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

Databox   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.48%

Importance

Changes 9
Bugs 0 Features 0
Metric Value
wmc 10
c 9
b 0
f 0
lcom 1
cbo 1
dl 0
loc 83
ccs 19
cts 21
cp 0.9048
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A fromList() 0 10 2
A fromValue() 0 4 1
A __construct() 0 4 1
A getVersion() 0 4 1
A getRawData() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A getLabels() 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
use Doctrine\Common\Collections\ArrayCollection;
15
16
class Databox
17
{
18
19 1
    public static function fromList(array $values)
20
    {
21 1
        $databoxes = array();
22
23 1
        foreach ($values as $value) {
24 1
            $databoxes[$value->databox_id] = self::fromValue($value);
25 1
        }
26
27 1
        return $databoxes;
28
    }
29
30 1
    public static function fromValue(\stdClass $value)
31
    {
32 1
        return new self($value);
33
    }
34
35
    /**
36
     * @var \stdClass
37
     */
38
    protected $source;
39
40
    /**
41
     * @var ArrayCollection
42
     */
43
    protected $labels;
44
45
    /**
46
     * @param \stdClass $source
47
     */
48 1
    public function __construct(\stdClass $source)
49
    {
50 1
        $this->source = $source;
51 1
    }
52
53
    /**
54
     * @return \stdClass
55
     */
56
    public function getRawData()
57
    {
58
        return $this->source;
59
    }
60
61
    /**
62
     * the databox id
63
     *
64
     * @return integer
65
     */
66 1
    public function getId()
67
    {
68 1
        return $this->source->databox_id;
69
    }
70
71
    /**
72
     * The databox name
73
     *
74
     * @return string
75
     */
76 1
    public function getName()
77
    {
78 1
        return $this->source->name;
79
    }
80
81
    /**
82
     * The databox version
83
     *
84
     * @return string
85
     */
86 1
    public function getVersion()
87
    {
88 1
        return $this->source->version;
89
    }
90
91
    /**
92
     * @return string[]
93
     */
94 1
    public function getLabels()
95
    {
96 1
        return $this->labels ?: $this->labels = new ArrayCollection((array) $this->source->labels);
97
    }
98
}
99