1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Shopware 5 |
4
|
|
|
* Copyright (c) shopware AG |
5
|
|
|
* |
6
|
|
|
* According to our dual licensing model, this program can be used either |
7
|
|
|
* under the terms of the GNU Affero General Public License, version 3, |
8
|
|
|
* or under a proprietary license. |
9
|
|
|
* |
10
|
|
|
* The texts of the GNU Affero General Public License with an additional |
11
|
|
|
* permission and of our proprietary license can be found at and |
12
|
|
|
* in the LICENSE file you have received along with this program. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* "Shopware" is a registered trademark of shopware AG. |
20
|
|
|
* The licensing of the program under the AGPLv3 does not imply a |
21
|
|
|
* trademark license. Therefore any rights, title and interest in |
22
|
|
|
* our trademarks remain entirely with us. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace Shopware\Components; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @category Shopware |
29
|
|
|
* @package Shopware\ |
30
|
|
|
* @copyright Copyright (c) shopware AG (http://www.shopware.de) |
31
|
|
|
*/ |
32
|
|
|
class StreetSplitService |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @param $street |
36
|
|
|
* @return mixed |
37
|
|
|
*/ |
38
|
|
|
public function split($street) |
39
|
|
|
{ |
40
|
|
|
preg_match('/(?P<streetNumber> [ ]{0,1}\d+[-]{0,1}\d*[a-z,A-Z]{0,1}\D{0,1})$/', $street, $matches); |
41
|
|
|
|
42
|
|
|
$matches['streetName'] = rtrim($street, $matches['streetNumber']); |
43
|
|
|
$matches['streetNumber'] = trim($matches['streetNumber']); |
44
|
|
|
|
45
|
|
|
// remove unnecessary numeric indexes |
46
|
|
|
unset($matches[0], $matches[1],$matches[2]); |
47
|
|
|
|
48
|
|
|
return $matches; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|