Skip to content

Commit f118535

Browse files
committed
Force php 7.1 or higher and use strict return types
1 parent 9cc92ee commit f118535

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

Client/PostcodeClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function fetchAddress($zipCode, $houseNumber)
7373

7474
$address->setLatitude($responseData['latitude']);
7575
$address->setLongitude($responseData['longitude']);
76+
$address->setProvince($responseData['province']);
7677

7778
return $address;
7879
}

Model/Address.php

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99
namespace ApiPostcode\Model;
1010

11+
use JsonSerializable;
12+
1113
/**
1214
* Class Address
1315
*
1416
* @author Api Postcode <info@api-postcode.nl>
1517
*/
16-
class Address implements \JsonSerializable
18+
class Address implements JsonSerializable
1719
{
1820
/** @var string */
1921
private $street;
@@ -27,19 +29,22 @@ class Address implements \JsonSerializable
2729
/** @var string */
2830
private $city;
2931

30-
/** @var string */
32+
/** @var float */
3133
private $latitude;
3234

33-
/** @var string */
35+
/** @var float */
3436
private $longitude;
3537

38+
/** @var string|null */
39+
private $province;
40+
3641
/**
3742
* @param string $street
3843
* @param string $zipCode
3944
* @param string $houseNumber
4045
* @param string $city
4146
*/
42-
public function __construct($street, $zipCode, $houseNumber, $city)
47+
public function __construct(string $street, string $zipCode, string $houseNumber, string $city)
4348
{
4449
$this->street = $street;
4550
$this->zipCode = $zipCode;
@@ -50,67 +55,83 @@ public function __construct($street, $zipCode, $houseNumber, $city)
5055
/**
5156
* @return string
5257
*/
53-
public function getStreet()
58+
public function getStreet(): string
5459
{
5560
return $this->street;
5661
}
5762

5863
/**
5964
* @return string
6065
*/
61-
public function getZipCode()
66+
public function getZipCode(): string
6267
{
6368
return $this->zipCode;
6469
}
6570

6671
/**
6772
* @return string
6873
*/
69-
public function getHouseNumber()
74+
public function getHouseNumber(): string
7075
{
7176
return $this->houseNumber;
7277
}
7378

7479
/**
7580
* @return string
7681
*/
77-
public function getCity()
82+
public function getCity(): string
7883
{
7984
return $this->city;
8085
}
8186

8287
/**
83-
* @return string
88+
* @return float
8489
*/
85-
public function getLatitude()
90+
public function getLatitude(): float
8691
{
8792
return $this->latitude;
8893
}
8994

9095
/**
91-
* @param string $latitude
96+
* @param float $latitude
9297
*/
93-
public function setLatitude($latitude)
98+
public function setLatitude(float $latitude)
9499
{
95100
$this->latitude = $latitude;
96101
}
97102

98103
/**
99-
* @return string
104+
* @return float
100105
*/
101-
public function getLongitude()
106+
public function getLongitude(): float
102107
{
103108
return $this->longitude;
104109
}
105110

106111
/**
107-
* @param string $longitude
112+
* @param float $longitude
108113
*/
109-
public function setLongitude($longitude)
114+
public function setLongitude(float $longitude)
110115
{
111116
$this->longitude = $longitude;
112117
}
113-
118+
119+
/**
120+
* @return string|null
121+
*/
122+
public function getProvince(): ?string
123+
{
124+
return $this->province;
125+
}
126+
127+
/**
128+
* @param string|null $province
129+
*/
130+
public function setProvince(?string $province): void
131+
{
132+
$this->province = $province;
133+
}
134+
114135
/**
115136
* @return array
116137
*/
@@ -122,15 +143,16 @@ public function toArray()
122143
'house_number' => $this->houseNumber,
123144
'zip_code' => $this->zipCode,
124145
'longitude' => $this->longitude,
125-
'latitude' => $this->latitude,
146+
'latitude' => $this->latitude,
147+
'province' => $this->province,
126148
);
127149
}
128-
150+
129151
/**
130152
* {@inheritdoc}
131153
*/
132-
function jsonSerialize()
154+
public function jsonSerialize()
133155
{
134156
return $this->toArray();
135-
}
157+
}
136158
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.5.9"
19+
"php": ">=7.1.0",
20+
"ext-json": "*"
2021
},
2122
"autoload": {
2223
"psr-4": {

0 commit comments

Comments
 (0)