|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** Location.php */ |
|
11
|
|
|
namespace Core\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Core\Entity\AbstractEntity; |
|
14
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
|
15
|
|
|
use GeoJson\GeoJson; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Location of a job position |
|
19
|
|
|
* |
|
20
|
|
|
* @ODM\EmbeddedDocument |
|
21
|
|
|
* @ODM\Index(keys={"coordinates"="2dsphere"}) |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
View Code Duplication |
class Location extends AbstractEntity implements LocationInterface |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* city name of a job location |
|
28
|
|
|
* |
|
29
|
|
|
* @ODM\Field(type="string") |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $city; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* region of a job location. E.g "Hessen" is a region in germany |
|
35
|
|
|
* |
|
36
|
|
|
* @ODM\Field(type="string") |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $region; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* postalcode of a job location. |
|
42
|
|
|
* |
|
43
|
|
|
* @var String |
|
44
|
|
|
* @ODM\Field(type="string") |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $postalcode; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* coordinates of a job location. |
|
50
|
|
|
* |
|
51
|
|
|
* @var GeoJson |
|
52
|
|
|
* @ODM\EmbedOne(discriminatorField="_entity") |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $coordinates; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Country of a job location |
|
58
|
|
|
* @var String |
|
59
|
|
|
* |
|
60
|
|
|
* @ODM\Field(type="string") |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $country; |
|
63
|
|
|
|
|
64
|
|
|
public function __construct() |
|
65
|
|
|
{ |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function preUpdate() |
|
69
|
|
|
{ |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getCoordinates() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->coordinates; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param GeoJson $coordinates |
|
79
|
|
|
* |
|
80
|
|
|
* @return $this |
|
81
|
|
|
*/ |
|
82
|
|
|
public function setCoordinates(GeoJson $coordinates) |
|
83
|
|
|
{ |
|
84
|
|
|
$this->coordinates = $coordinates; |
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return String |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getPostalcode() |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->postalcode; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param $postalcode |
|
98
|
|
|
* |
|
99
|
|
|
* @return $this |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setPostalcode($postalcode) |
|
102
|
|
|
{ |
|
103
|
|
|
$this->postalcode = $postalcode; |
|
104
|
|
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return mixed |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getCity() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->city; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param $city |
|
117
|
|
|
* |
|
118
|
|
|
* @return $this |
|
119
|
|
|
*/ |
|
120
|
|
|
public function setCity($city) |
|
121
|
|
|
{ |
|
122
|
|
|
$this->city = $city; |
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return String |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getCountry() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->country; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param $country |
|
136
|
|
|
* |
|
137
|
|
|
* @return $this |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setCountry($country) |
|
140
|
|
|
{ |
|
141
|
|
|
$this->country = $country; |
|
142
|
|
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return mixed |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getRegion() |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->region; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @param $region |
|
155
|
|
|
* |
|
156
|
|
|
* @return $this |
|
157
|
|
|
*/ |
|
158
|
|
|
public function setRegion($region) |
|
159
|
|
|
{ |
|
160
|
|
|
$this->region = $region; |
|
161
|
|
|
return $this; |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
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.