Passed
Push — master ( 54a344...83c53d )
by Mario
03:09
created

StreetSplitService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A split() 0 12 1
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
 * @category  Shopware
28
 * @package   Shopware\
29
 * @copyright Copyright (c) shopware AG (http://www.shopware.de)
30
 */
31
class StreetSplitService {
32
33
    public function split($street)
34
    {
35
        preg_match("/(?P<streetNumber> \d+[ ]{0,1}\D{0,1})$/", $street, $matches);
36
37
        $matches['streetName'] = rtrim($street, $matches['streetNumber']);
38
        $matches['streetNumber'] = trim($matches['streetNumber']);
39
40
        // remove unnecessary numeric indexes
41
        unset($matches[0], $matches[1],$matches[2]);
42
43
        return $matches;
44
    }
45
46
}