1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\BusinessEntityBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @ORM\Entity(repositoryClass="Victoire\Bundle\BusinessEntityBundle\Entity\BusinessPropertyRepository") |
9
|
|
|
* @ORM\Table("vic_business_property") |
10
|
|
|
*/ |
11
|
|
|
class BusinessProperty |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var int |
15
|
|
|
* |
16
|
|
|
* @ORM\Column(name="id", type="integer") |
17
|
|
|
* @ORM\Id |
18
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
19
|
|
|
*/ |
20
|
|
|
protected $id; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
* |
25
|
|
|
* @ORM\Column(name="types", type="text", nullable=true) |
26
|
|
|
*/ |
27
|
|
|
protected $types = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
* |
32
|
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=true) |
33
|
|
|
*/ |
34
|
|
|
protected $name = null; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @ORM\ManyToOne(targetEntity="Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntity", inversedBy="businessProperties") |
38
|
|
|
*/ |
39
|
|
|
protected $businessEntity; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(name="choices", type="text", nullable=true) |
45
|
|
|
*/ |
46
|
|
|
protected $choices; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(name="listMethod", type="text", nullable=true) |
52
|
|
|
*/ |
53
|
|
|
protected $listMethod; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(name="filterMethod", type="text", nullable=true) |
59
|
|
|
*/ |
60
|
|
|
protected $filterMethod; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Set the type. |
64
|
|
|
* |
65
|
|
|
* @param string $types |
66
|
|
|
*/ |
67
|
|
View Code Duplication |
public function setTypes($types) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
$data = @unserialize($types); |
70
|
|
|
if ($types === 'b:0;' || $data !== false) { |
71
|
|
|
$this->types = $types; |
72
|
|
|
} else { |
73
|
|
|
$this->types = serialize($types); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return string the type of business property |
79
|
|
|
*/ |
80
|
|
|
public function getTypes() |
81
|
|
|
{ |
82
|
|
|
if (!$this->types) { |
83
|
|
|
return []; |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return unserialize($this->types); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Display object as string. |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function __toString() |
95
|
|
|
{ |
96
|
|
|
return $this->name; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return BusinessEntity |
101
|
|
|
*/ |
102
|
|
|
public function getBusinessEntity() |
103
|
|
|
{ |
104
|
|
|
return $this->businessEntity; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param BusinessEntity $businessEntity |
109
|
|
|
*/ |
110
|
|
|
public function setBusinessEntity(BusinessEntity $businessEntity) |
111
|
|
|
{ |
112
|
|
|
$this->businessEntity = $businessEntity; |
113
|
|
|
$businessEntity->addBusinessProperty($this); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return int |
118
|
|
|
*/ |
119
|
|
|
public function getId() |
120
|
|
|
{ |
121
|
|
|
return $this->id; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getName() |
128
|
|
|
{ |
129
|
|
|
return $this->name; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param string $name |
134
|
|
|
*/ |
135
|
|
|
public function setName($name) |
136
|
|
|
{ |
137
|
|
|
$this->name = $name; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set the choices. |
142
|
|
|
* |
143
|
|
|
* @param string $choices |
144
|
|
|
*/ |
145
|
|
View Code Duplication |
public function setChoices($choices) |
|
|
|
|
146
|
|
|
{ |
147
|
|
|
$data = @unserialize($choices); |
148
|
|
|
if ($choices === 'b:0;' || $data !== false) { |
149
|
|
|
$this->choices = $choices; |
|
|
|
|
150
|
|
|
} else { |
151
|
|
|
$this->choices = serialize($choices); |
|
|
|
|
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return string the choice of business property |
157
|
|
|
*/ |
158
|
|
|
public function getChoices() |
159
|
|
|
{ |
160
|
|
|
if (!$this->choices) { |
|
|
|
|
161
|
|
|
return []; |
|
|
|
|
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
return unserialize($this->choices); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return string |
169
|
|
|
*/ |
170
|
|
|
public function getListMethod() |
171
|
|
|
{ |
172
|
|
|
return $this->listMethod; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param string $listMethod |
177
|
|
|
*/ |
178
|
|
|
public function setListMethod($listMethod) |
179
|
|
|
{ |
180
|
|
|
$this->listMethod = $listMethod; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return string |
185
|
|
|
*/ |
186
|
|
|
public function getFilterMethod() |
187
|
|
|
{ |
188
|
|
|
return $this->filterMethod; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param string $filterMethod |
193
|
|
|
*/ |
194
|
|
|
public function setFilterMethod($filterMethod) |
195
|
|
|
{ |
196
|
|
|
$this->filterMethod = $filterMethod; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param string $type |
201
|
|
|
*/ |
|
|
|
|
202
|
|
|
public function hasType($type) |
203
|
|
|
{ |
204
|
|
|
return in_array($type, $this->getTypes()); |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.