AddressClaim::setFormatted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: GCC-MED
5
 * Date: 29/01/2018
6
 * Time: 15:34
7
 */
8
9
namespace OAuth2OLD\OpenID\Models;
10
11
12
class AddressClaim implements \JsonSerializable
13
{
14
    /**
15
     * @var null|string
16
     */
17
    protected $formatted;
18
    /**
19
     * @var null|string
20
     */
21
    protected $streetAddress;
22
    /**
23
     * @var null|string
24
     */
25
    protected $locality;
26
    /**
27
     * @var null|string
28
     */
29
    protected $region;
30
    /**
31
     * @var string
32
     */
33
    protected $postalCode;
34
    /**
35
     * @var null|string
36
     */
37
    protected $country;
38
39
    /**
40
     * @return null|string
41
     */
42
    public function getFormatted(): ?string
43
    {
44
        return $this->formatted;
45
    }
46
47
    /**
48
     * @param null|string $formatted
49
     */
50
    public function setFormatted(?string $formatted)
51
    {
52
        $this->formatted = $formatted;
53
    }
54
55
    /**
56
     * @return null|string
57
     */
58
    public function getStreetAddress(): ?string
59
    {
60
        return $this->streetAddress;
61
    }
62
63
    /**
64
     * @param null|string $streetAddress
65
     */
66
    public function setStreetAddress(?string $streetAddress)
67
    {
68
        $this->streetAddress = $streetAddress;
69
    }
70
71
    /**
72
     * @return null|string
73
     */
74
    public function getLocality(): ?string
75
    {
76
        return $this->locality;
77
    }
78
79
    /**
80
     * @param null|string $locality
81
     */
82
    public function setLocality(?string $locality)
83
    {
84
        $this->locality = $locality;
85
    }
86
87
    /**
88
     * @return null|string
89
     */
90
    public function getRegion(): ?string
91
    {
92
        return $this->region;
93
    }
94
95
    /**
96
     * @param null|string $region
97
     */
98
    public function setRegion(?string $region)
99
    {
100
        $this->region = $region;
101
    }
102
103
    /**
104
     * @return null|string
105
     */
106
    public function getPostalCode(): ?string
107
    {
108
        return $this->postalCode;
109
    }
110
111
    /**
112
     * @param null|string $postalCode
113
     */
114
    public function setPostalCode(?string $postalCode)
115
    {
116
        $this->postalCode = $postalCode;
117
    }
118
119
    /**
120
     * @return null|string
121
     */
122
    public function getCountry(): ?string
123
    {
124
        return $this->country;
125
    }
126
127
    /**
128
     * @param null|string $country
129
     */
130
    public function setCountry(?string $country)
131
    {
132
        $this->country = $country;
133
    }
134
135
    /**
136
     * Specify data which should be serialized to JSON
137
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
138
     * @return mixed data which can be serialized by <b>json_encode</b>,
139
     * which is a value of any type other than a resource.
140
     * @since 5.4.0
141
     */
142
public function jsonSerialize()
143
    {
144
        $data = [];
145
        if($this->formatted) {
146
            $data['formatted'] = $this->formatted;
147
        }
148
        if($this->streetAddress) {
149
            $data['street_address'] = $this->streetAddress;
150
        }
151
        if($this->locality) {
152
            $data['locality'] = $this->locality;
153
        }
154
        if($this->region) {
155
            $data['region'] = $this->region;
156
        }
157
        if($this->postalCode) {
158
            $data['postal_code'] = $this->postalCode;
159
        }
160
        if($this->country) {
161
            $data['country'] = $this->country;
162
        }
163
        return empty($data) ? '' : json_encode($data);
164
    }
165
}