Completed
Push — master ( fc837a...0d3833 )
by Rafał
05:57
created

WidgetModel::getTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Templates System.
5
 *
6
 * Copyright 2015 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\TemplatesSystem\Tests\Gimme\Model;
16
17
use SWP\Component\TemplatesSystem\Gimme\Model\WidgetModelInterface;
18
19
/**
20
 * WidgetModel.
21
 */
22
class WidgetModel implements WidgetModelInterface
23
{
24
    /**
25
     * @var int
26
     */
27
    protected $id;
28
29
    /**
30
     * @var string
31
     */
32
    protected $type;
33
34
    /**
35
     * @var string
36
     */
37
    protected $name;
38
39
    /**
40
     * @var bool
41
     */
42
    protected $visible;
43
44
    /**
45
     * @var array
46
     */
47
    protected $parameters;
48
49
    public function __construct()
50
    {
51
        $this->parameters = [];
52
        $this->setVisible(true);
53
    }
54
55
    public function getTypes(): array
56
    {
57
        return [
58
            self::TYPE_HTML => '\\SWP\\Component\\TemplatesSystem\\Gimme\\WidgetModel\\HtmlWidgetHandler',
59
        ];
60
    }
61
62
    /**
63
     * Get id.
64
     *
65
     * @return int
66
     */
67
    public function getId()
68
    {
69
        return $this->id;
70
    }
71
72
    /**
73
     * Set id.
74
     *
75
     * @param int $id
76
     *
77
     * @return WidgetModel
78
     */
79
    public function setId($id)
80
    {
81
        $this->id = $id;
82
83
        return $this;
84
    }
85
86
    /**
87
     * Set name.
88
     *
89
     * @param string $name
90
     *
91
     * @return WidgetModel
92
     */
93
    public function setName($name)
94
    {
95
        $this->name = $name;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Get name.
102
     *
103
     * @return string
104
     */
105
    public function getName()
106
    {
107
        return $this->name;
108
    }
109
110
    /**
111
     * Gets the value of visible.
112
     *
113
     * @return bool
114
     */
115
    public function getVisible()
116
    {
117
        return $this->visible;
118
    }
119
120
    /**
121
     * Sets the value of visible.
122
     *
123
     * @param bool $visible the visible
124
     *
125
     * @return WidgetModel
126
     */
127
    public function setVisible($visible)
128
    {
129
        $this->visible = $visible;
130
131
        return $this;
132
    }
133
134
    /**
135
     * Gets the value of type.
136
     *
137
     * @return int
138
     */
139
    public function getType()
140
    {
141
        return $this->type;
142
    }
143
144
    /**
145
     * Sets the value of type.
146
     *
147
     * @param int $type the type
148
     *
149
     * @return WidgetModel
150
     */
151
    public function setType($type = self::TYPE_HTML)
152
    {
153
        if (array_key_exists($type, $this->getTypes())) {
154
            $this->type = $this->getTypes()[$type];
155
        } else {
156
            $this->type = $this->getTypes()[self::TYPE_HTML];
157
        }
158
159
        return $this;
160
    }
161
162
    /**
163
     * Gets the value of parameters.
164
     *
165
     * @return array
166
     */
167
    public function getParameters()
168
    {
169
        return $this->parameters;
170
    }
171
172
    /**
173
     * Sets the value of parameters.
174
     *
175
     * @param array $parameters the parameters
176
     *
177
     * @return WidgetModel
178
     */
179
    public function setParameters(array $parameters = [])
180
    {
181
        $this->parameters = $parameters;
182
183
        return $this;
184
    }
185
}
186