TemplateType::setLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Synapse\Cmf\Framework\Theme\TemplateType\Entity;
4
5
use Majora\Framework\Normalizer\Model\NormalizableTrait;
6
use Synapse\Cmf\Framework\Theme\TemplateType\Model\TemplateTypeInterface;
7
use Synapse\Cmf\Framework\Theme\ZoneType\Entity\ZoneTypeCollection;
8
9
/**
10
 * TemplateType entity class.
11
 */
12
class TemplateType implements TemplateTypeInterface
13
{
14
    use NormalizableTrait;
15
16
    /**
17
     * @var int
18
     */
19
    protected $id;
20
21
    /**
22
     * @var string
23
     */
24
    protected $name;
25
26
    /**
27
     * @var array
28
     */
29
    protected $labels;
30
31
    /**
32
     * @var ZoneTypeCollection
33
     */
34
    protected $zoneTypes;
35
36
    /**
37
     * @see NormalizableInterface::getScopes()
38
     */
39 6
    public static function getScopes()
40
    {
41
        return array(
42 6
            'id' => 'id',
43 3
            'default' => array('id'),
44 3
        );
45
    }
46
47
    /**
48
     * Construct.
49
     */
50 34
    public function __construct()
51
    {
52 34
        $this->labels = array();
53 34
        $this->zoneTypes = new ZoneTypeCollection();
54 34
    }
55
56
    /**
57
     * Returns TemplateType id.
58
     *
59
     * @return int
60
     */
61 10
    public function getId()
62
    {
63 10
        return $this->id;
64
    }
65
66
    /**
67
     * Define TemplateType id.
68
     *
69
     * @param int $id
70
     *
71
     * @return self
72
     */
73 12
    public function setId($id)
74
    {
75 12
        $this->id = $id;
76
77 12
        return $this;
78
    }
79
80
    /**
81
     * Returns TemplateType name.
82
     *
83
     * @return string
84
     */
85 2
    public function getName()
86
    {
87 2
        return $this->name;
88
    }
89
90
    /**
91
     * Define TemplateType name.
92
     *
93
     * @param string $name
94
     *
95
     * @return self
96
     */
97 2
    public function setName($name)
98
    {
99 2
        $this->name = $name;
100
101 2
        return $this;
102
    }
103
104
    /**
105
     * Returns TemplateType labels.
106
     *
107
     * @return array
108
     */
109 2
    public function getLabels()
110
    {
111 2
        return $this->labels;
112
    }
113
114
    /**
115
     * Define TemplateType labels.
116
     *
117
     * @param array $labels
118
     *
119
     * @return self
120
     */
121 2
    public function setLabels(array $labels)
122
    {
123 2
        $this->labels = $labels;
124
125 2
        return $this;
126
    }
127
128
    /**
129
     * Returns TemplateType zone types.
130
     *
131
     * @return ZoneTypeCollection
132
     */
133 4
    public function getZoneTypes()
134
    {
135 4
        return $this->zoneTypes;
136
    }
137
138
    /**
139
     * Define TemplateType zone types.
140
     *
141
     * @param ZoneTypeCollection $zoneTypes
142
     *
143
     * @return self
144
     */
145 2
    public function setZoneTypes(ZoneTypeCollection $zoneTypes)
146
    {
147 2
        $this->zoneTypes = $zoneTypes;
148
149 2
        return $this;
150
    }
151
152
    /**
153
     * Tests if this TemplateType supports given content type from given content types list.
154
     *
155
     * @param string $contentType
156
     * @param array  $contentTypes
157
     *
158
     * @return bool
159
     */
160 6
    public function supportsContentType($contentType, array $contentTypes)
161
    {
162 6
        return empty($contentTypes)
163 5
            || in_array($contentType, $contentTypes)
164 3
        ;
165
    }
166
}
167