Completed
Pull Request — master (#6)
by Paweł
05:54
created

Widget   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 163
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 12
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 163
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A setId() 0 6 1
A setName() 0 6 1
A getName() 0 4 1
A getVisible() 0 4 1
A setVisible() 0 6 1
A getType() 0 4 1
A setType() 0 10 2
A getParameters() 0 4 1
A setParameters() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Templates System
5
 *
6
 * Copyright 2015 Sourcefabric z.u. 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\TemplatesSystem\Tests\Gimme\Model;
16
17
use SWP\TemplatesSystem\Gimme\Model\WidgetInterface;
18
use Doctrine\Common\Collections\ArrayCollection;
19
20
/**
21
 * Widget.
22
 */
23
class Widget implements WidgetInterface
24
{
25
    const TYPE_HTML = 1;
26
27
    protected $types = [
28
        self::TYPE_HTML => "\\SWP\\TemplatesSystem\\Gimme\\Widget\\HtmlWidget"
29
    ];
30
31
    /**
32
     * @var int
33
     */
34
    protected $id;
35
36
    /**
37
     * @var string
38
     */
39
    protected $type;
40
41
    /**
42
     * @var string
43
     */
44
    protected $name;
45
46
    /**
47
     * @var boolean
48
     */
49
    protected $visible;
50
51
    /**
52
     * @var []
53
     */
54
    protected $parameters;
55
56
    public function __construct()
57
    {
58
        $this->parameters = [];
59
        $this->setVisible(true);
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 string $id
76
     *
77
     * @return self
78
     */
79
    public function setId($id)
80
    {
81
        $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type integer, but $id is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
82
83
        return $this;
84
    }
85
86
    /**
87
     * Set name.
88
     *
89
     * @param string $name
90
     *
91
     * @return self
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 boolean
114
     */
115
    public function getVisible()
116
    {
117
        return $this->visible;
118
    }
119
120
    /**
121
     * Sets the value of visible.
122
     *
123
     * @param boolean $visible the visible
124
     *
125
     * @return self
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 integer
138
     */
139
    public function getType()
140
    {
141
        return $this->type;
142
    }
143
144
    /**
145
     * Sets the value of type.
146
     *
147
     * @param integer $type the type
148
     *
149
     * @return self
150
     */
151
    public function setType($type = self::TYPE_HTML)
152
    {
153
        if (array_key_exists($type, $this->types)) {
154
            $this->type = $this->types[$type];
155
        } else {
156
            $this->type = $this->types[self::TYPE_HTML];
157
        }
158
159
        return $this;
160
    }
161
162
    /**
163
     * Gets the value of parameters.
164
     *
165
     * @return []
0 ignored issues
show
Documentation introduced by
The doc-type [] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
166
     */
167
    public function getParameters()
168
    {
169
        return $this->parameters;
170
    }
171
172
    /**
173
     * Sets the value of parameters.
174
     *
175
     * @param [] $parameters the parameters
0 ignored issues
show
Documentation introduced by
The doc-type [] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
176
     *
177
     * @return self
178
     */
179
    public function setParameters($parameters)
180
    {
181
        $this->parameters = $parameters;
182
183
        return $this;
184
    }
185
}
186