Completed
Pull Request — master (#812)
by Paul
05:35
created

EntityProxy::getEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Victoire\Bundle\CoreBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity;
7
use Victoire\Bundle\WidgetBundle\Entity\Widget;
8
9
/**
10
 * The Entity proxy is the link between a view, a widget or any else with the BusinessEntity.
11
 *
12
 * @ORM\Table("vic_entity_proxy")
13
 * @ORM\Entity()
14
 */
15
class EntityProxy
16
{
17
    /**
18
     * @var int
19
     *
20
     * @ORM\Column(name="id", type="integer")
21
     * @ORM\Id
22
     * @ORM\GeneratedValue(strategy="AUTO")
23
     */
24
    protected $id;
25
26
    /**
27
     * @var string
28
     *
29
     * @ORM\OneToMany(targetEntity="\Victoire\Bundle\WidgetBundle\Entity\Widget", mappedBy="entityProxy")
30
     * @ORM\OrderBy({"id" = "ASC"})
31
     */
32
    protected $widgets;
33
34
    /**
35
     * id of the ressource (could be an integer, an hash...).
36
     *
37
     * @ORM\Column(type="string", length=255, nullable=true)
38
     */
39
    protected $ressourceId;
40
41
    /**
42
     * @var BusinessEntity
43
     *
44
     * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity")
45
     * @ORM\JoinColumn(name="business_entity_id", referencedColumnName="id", onDelete="CASCADE")
46
     */
47
    protected $businessEntity;
48
    protected $entity;
49
50
    /**
51
     * This is used to pass additionnal informations to the API call, like the format (eg. lite, full...) or to give some
52
     * filters (eg. ?color=red...).
53
     *
54
     * @var array
55
     *
56
     * @ORM\Column(type="text", nullable=true)
57
     */
58
    protected $additionnalProperties;
59
60
    /**
61
     * Get id.
62
     *
63
     * @return int
64
     */
65
    public function getId()
66
    {
67
        return $this->id;
68
    }
69
70
    /**
71
     * @param int $id
72
     */
73
    public function setId($id)
74
    {
75
        $this->id = $id;
76
    }
77
78
    /**
79
     * Get the entity of the proxy.
80
     *
81
     * @throws \Exception
82
     *
83
     * @return mixed
84
     */
85
    public function getEntity()
86
    {
87
        return $this->entity;
88
    }
89
90
    /**
91
     * Set the entity.
92
     *
93
     * @param $entity
94
     * @param $entityId
95
     *
96
     * @throws \Exception
97
     */
98
    public function setEntity($entity)
99
    {
100
        $this->entity = $entity;
101
    }
102
103
    /**
104
     * Set widgets.
105
     *
106
     * @param array $widgets
107
     *
108
     * @return EntityProxy
109
     */
110
    public function setWidgets($widgets)
111
    {
112
        $this->widgets = $widgets;
0 ignored issues
show
Documentation Bug introduced by
It seems like $widgets of type array is incompatible with the declared type string of property $widgets.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
113
114
        foreach ($widgets as $widget) {
115
            $widget->setView($this);
116
        }
117
118
        return $this;
119
    }
120
121
    /**
122
     * Get widgets.
123
     *
124
     * @return string
125
     */
126
    public function getWidgets()
127
    {
128
        return $this->widgets;
129
    }
130
131
    /**
132
     * Add widget.
133
     *
134
     * @param Widget $widget
135
     */
136
    public function addWidget(Widget $widget)
137
    {
138
        $this->widgets[] = $widget;
139
    }
140
141
    /**
142
     * Remove widget.
143
     *
144
     * @param Widget $widget
145
     */
146
    public function removeWidget(Widget $widget)
147
    {
148
        $this->widgets->remove($widget);
0 ignored issues
show
Bug introduced by
The method remove cannot be called on $this->widgets (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
149
    }
150
151
    /**
152
     * has widget.
153
     *
154
     * @param Widget $widget
155
     *
156
     * @return bool
157
     */
158
    public function hasWidget(Widget $widget)
159
    {
160
        return $this->widgets->contains($widget);
0 ignored issues
show
Bug introduced by
The method contains cannot be called on $this->widgets (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
161
    }
162
163
    /**
164
     * @return BusinessEntity
165
     */
166
    public function getBusinessEntity()
167
    {
168
        return $this->businessEntity;
169
    }
170
171
    /**
172
     * @param BusinessEntity $businessEntity
173
     */
174
    public function setBusinessEntity($businessEntity)
175
    {
176
        $this->businessEntity = $businessEntity;
177
    }
178
179
    /**
180
     * @return mixed
181
     */
182
    public function getRessourceId()
183
    {
184
        return $this->ressourceId;
185
    }
186
187
    /**
188
     * @param mixed $ressource
0 ignored issues
show
Documentation introduced by
There is no parameter named $ressource. Did you maybe mean $ressourceId?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
189
     */
190
    public function setRessourceId($ressourceId)
191
    {
192
        $this->ressourceId = $ressourceId;
193
    }
194
195
    /**
196
     * @return array
197
     */
198
    public function getAdditionnalProperties()
199
    {
200
        return unserialize($this->additionnalProperties);
201
    }
202
203
    /**
204
     * @param array $additionnalProperties
205
     */
206
    public function setAdditionnalProperties($additionnalProperties)
207
    {
208
        $this->additionnalProperties = serialize($additionnalProperties);
0 ignored issues
show
Documentation Bug introduced by
It seems like serialize($additionnalProperties) of type string is incompatible with the declared type array of property $additionnalProperties.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
209
    }
210
}
211