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

Metadata   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 82.61%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 10
c 8
b 0
f 0
lcom 0
cbo 0
dl 0
loc 85
ccs 19
cts 23
cp 0.8261
rs 10

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