Passed
Push — master ( 138f6a...e189b2 )
by Torben
66:36 queued 63:19
created

Location::getFullAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 14
ccs 2
cts 2
cp 1
crap 1
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.txt file that was distributed with this source code.
8
 */
9
10
namespace DERHANSEN\SfEventMgt\Domain\Model;
11
12
/**
13
 * Location
14
 */
15
class Location extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
16
{
17
    /**
18
     * Title
19
     *
20
     * @var string
21
     */
22
    protected $title = '';
23
24
    /**
25
     * Address
26
     *
27
     * @var string
28
     */
29
    protected $address = '';
30
31
    /**
32
     * Zip
33
     *
34
     * @var string
35
     */
36
    protected $zip = '';
37
38
    /**
39
     * City
40
     *
41
     * @var string
42
     */
43
    protected $city = '';
44
45
    /**
46
     * Country
47
     *
48
     * @var string
49
     */
50
    protected $country = '';
51
52
    /**
53
     * Description
54
     *
55
     * @var string
56
     */
57
    protected $description = '';
58
59
    /**
60
     * Link
61
     *
62
     * @var string
63
     */
64
    protected $link = '';
65
66
    /**
67
     * Longitude
68
     *
69
     * @var float
70
     */
71
    protected $longitude = 0.0;
72
73
    /**
74
     * Latitude
75
     *
76
     * @var float
77
     */
78
    protected $latitude = 0.0;
79
80
    /**
81
     * Returns the title
82
     *
83
     * @return string $title
84
     */
85
    public function getTitle()
86
    {
87
        return $this->title;
88
    }
89
90
    /**
91
     * Sets the title
92
     *
93 2
     * @param string $title The title
94
     */
95 2
    public function setTitle($title)
96
    {
97
        $this->title = $title;
98
    }
99
100
    /**
101
     * Returns the address
102
     *
103
     * @return string $address
104
     */
105 2
    public function getAddress()
106
    {
107 2
        return $this->address;
108 2
    }
109
110
    /**
111
     * Sets the address
112
     *
113
     * @param string $address Address
114
     */
115 2
    public function setAddress($address)
116
    {
117 2
        $this->address = $address;
118
    }
119
120
    /**
121
     * Returns the zip
122
     *
123
     * @return string $zip
124
     */
125
    public function getZip()
126
    {
127 2
        return $this->zip;
128
    }
129 2
130 2
    /**
131
     * Sets the zip
132
     *
133
     * @param string $zip Zip
134
     */
135
    public function setZip($zip)
136
    {
137 2
        $this->zip = $zip;
138
    }
139 2
140
    /**
141
     * Returns the city
142
     *
143
     * @return string $city
144
     */
145
    public function getCity()
146
    {
147
        return $this->city;
148
    }
149 2
150
    /**
151 2
     * Sets the city
152 2
     *
153
     * @param string $city City
154
     */
155
    public function setCity($city)
156
    {
157
        $this->city = $city;
158
    }
159 2
160
    /**
161 2
     * Returns the country
162
     *
163
     * @return string $country
164
     */
165
    public function getCountry()
166
    {
167
        return $this->country;
168
    }
169
170
    /**
171 2
     * Sets the country
172
     *
173 2
     * @param string $country Country
174 2
     */
175
    public function setCountry($country)
176
    {
177
        $this->country = $country;
178
    }
179
180
    /**
181 2
     * Returns the description
182
     *
183 2
     * @return string $description
184
     */
185
    public function getDescription()
186
    {
187
        return $this->description;
188
    }
189
190
    /**
191
     * Sets the description
192
     *
193 2
     * @param string $description The description
194
     */
195 2
    public function setDescription($description)
196 2
    {
197
        $this->description = $description;
198
    }
199
200
    /**
201
     * Returns link
202
     *
203 2
     * @return string
204
     */
205 2
    public function getLink()
206
    {
207
        return $this->link;
208
    }
209
210
    /**
211
     * Sets link
212
     *
213
     * @param string $link
214
     */
215 2
    public function setLink($link)
216
    {
217 2
        $this->link = $link;
218 2
    }
219
220
    /**
221
     * Returns the longitude
222
     *
223
     * @return float
224
     */
225 2
    public function getLongitude()
226
    {
227 2
        return $this->longitude;
228
    }
229
230
    /**
231
     * Sets the the longitude
232
     *
233
     * @param float $longitude The longitude
234
     */
235
    public function setLongitude($longitude)
236 2
    {
237
        $this->longitude = $longitude;
238 2
    }
239 2
240
    /**
241
     * Returns the latitude
242
     *
243
     * @return float
244
     */
245
    public function getLatitude()
246 4
    {
247
        return $this->latitude;
248 4
    }
249
250
    /**
251
     * Sets the latitude
252
     *
253
     * @param float $latitude The latitude
254
     */
255
    public function setLatitude($latitude)
256
    {
257
        $this->latitude = $latitude;
258 2
    }
259
260 2
    /**
261 2
     * Special getter to return the full address of the location
262
     *
263
     * @param string $separator
264
     * @return string
265
     */
266
    public function getFullAddress(string $separator = '<br/>'): string
267
    {
268 4
        $locationData = [];
269
        $locationData[] = $this->getTitle();
270 4
        $locationData[] = $this->getAddress();
271
        $locationData[] = trim($this->getZip() . ' ' . $this->getCity());
272
        $locationData[] = $this->getCountry();
273
        $locationData = array_filter(
274
            $locationData,
275
            function ($value) {
276
                return str_replace(' ', '', $value) !== '';
277
            }
278
        );
279
        return implode($separator, $locationData);
280 2
    }
281
}
282