PhotonAddress   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
eloc 21
c 2
b 0
f 0
dl 0
loc 87
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A withOSMTag() 0 14 3
A withOSMId() 0 6 1
A withOSMType() 0 6 1
A getOSMTag() 0 3 1
A getOSMType() 0 3 1
A getOSMId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\Photon\Model;
14
15
use Geocoder\Model\Address;
16
17
/**
18
 * @author Jonathan Beliën <[email protected]>
19
 */
20
final class PhotonAddress extends Address
21
{
22
    /**
23
     * @var int|null
24
     */
25
    private $osmId;
26
27
    /**
28
     * @var string|null
29
     */
30
    private $osmType;
31
32
    /**
33
     * @var \stdclass|null
34
     */
35
    private $osmTag;
36
37
    /**
38
     * @return int|null
39
     */
40
    public function getOSMId()
41
    {
42
        return $this->osmId;
43
    }
44
45
    /**
46
     * @param int|null $osmId
47
     *
48
     * @return PhotonAddress
49
     */
50
    public function withOSMId(int $osmId = null): self
51
    {
52
        $new = clone $this;
53
        $new->osmId = $osmId;
54
55
        return $new;
56
    }
57
58
    /**
59
     * @return string|null
60
     */
61
    public function getOSMType()
62
    {
63
        return $this->osmType;
64
    }
65
66
    /**
67
     * @param string|null $osmType
68
     *
69
     * @return PhotonAddress
70
     */
71
    public function withOSMType(string $osmType = null): self
72
    {
73
        $new = clone $this;
74
        $new->osmType = $osmType;
75
76
        return $new;
77
    }
78
79
    /**
80
     * @return object|null
81
     */
82
    public function getOSMTag()
83
    {
84
        return $this->osmTag;
85
    }
86
87
    /**
88
     * @param string|null $key
89
     * @param string|null $value
90
     *
91
     * @return PhotonAddress
92
     */
93
    public function withOSMTag(string $key = null, string $value = null): self
94
    {
95
        $new = clone $this;
96
97
        if (!is_null($key) && !is_null($value)) {
98
            $new->osmTag = (object) [
99
                'key' => $key,
100
                'value' => $value,
101
            ];
102
        } else {
103
            $new->osmTag = null;
104
        }
105
106
        return $new;
107
    }
108
}
109