Skip to content

Commit c587b34

Browse files
committed
Using a class variable instead of the JsonSerializable interface to remain compatible with PHP 5.3 and not require minimum 5.4.
1 parent cf59bae commit c587b34

File tree

10 files changed

+35
-80
lines changed

10 files changed

+35
-80
lines changed

src/org/nameapi/ontology/input/entities/address/AddressRelation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
* Specifies for what purposes a certain InputAddress is, for example for AddressUsage CORRESPONDENCE.
88
*/
9-
abstract class AddressRelation implements \JsonSerializable {
9+
abstract class AddressRelation {
1010

1111
}
1212

src/org/nameapi/ontology/input/entities/address/InputAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @see StructuredAddressBuilder
1010
*/
11-
abstract class InputAddress implements \JsonSerializable {
11+
abstract class InputAddress {
1212

1313
}
1414

src/org/nameapi/ontology/input/entities/address/PlaceInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* - country
1313
*
1414
*/
15-
abstract class PlaceInfo implements \JsonSerializable {
15+
abstract class PlaceInfo {
1616

1717
}
1818

src/org/nameapi/ontology/input/entities/address/StreetInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* - apartment/suite
1212
*
1313
*/
14-
abstract class StreetInfo implements \JsonSerializable {
14+
abstract class StreetInfo {
1515

1616
}
1717

src/org/nameapi/ontology/input/entities/address/StructuredAddress.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ static function builder() {
2020
return new StructuredAddressBuilder();
2121
}
2222

23+
/**
24+
* Used for JSON marshalling only.
25+
*/
26+
public $type = 'StructuredAddress';
2327

2428
/**
2529
* @var StreetInfo|null $streetInfo
@@ -45,15 +49,5 @@ public function __construct($streetInfo, $pobox, $placeInfo) {
4549
$this->placeInfo = $placeInfo;
4650
}
4751

48-
public function jsonSerialize() {
49-
return array(
50-
'type' => "StructuredAddress",
51-
'streetInfo' => $this->streetInfo,
52-
'pobox' => $this->pobox,
53-
'placeInfo' => $this->placeInfo,
54-
);
55-
}
56-
57-
5852
}
5953

src/org/nameapi/ontology/input/entities/address/StructuredPlaceInfo.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ static function builder() {
1616
return new StructuredPlaceInfoBuilder();
1717
}
1818

19+
/**
20+
* Used for JSON marshalling only.
21+
*/
22+
public $type = 'StructuredPlaceInfo';
23+
1924

2025
/**
2126
* @var string|null $locality
@@ -53,17 +58,5 @@ public function __construct($locality, $postalCode, $neighborhood, $region, $cou
5358
$this->country = $country;
5459
}
5560

56-
57-
public function jsonSerialize() {
58-
return array(
59-
'type' => "StructuredPlaceInfo",
60-
'locality' => $this->locality,
61-
'postalCode' => $this->postalCode,
62-
'neighborhood' => $this->neighborhood,
63-
'region' => $this->region,
64-
'country' => $this->country,
65-
);
66-
}
67-
6861
}
6962

src/org/nameapi/ontology/input/entities/address/StructuredStreetInfo.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ static function builder() {
1616
return new StructuredStreetInfoBuilder();
1717
}
1818

19+
/**
20+
* Used for JSON marshalling only.
21+
*/
22+
public $type = 'StructuredStreetInfo';
23+
1924

2025
/**
2126
* @var string|null $streetName
@@ -61,18 +66,5 @@ public function __construct($streetName, $houseNumber, $building, $staircase, $f
6166
$this->apartment = $apartment;
6267
}
6368

64-
65-
public function jsonSerialize() {
66-
return array(
67-
'type' => "StructuredStreetInfo",
68-
'streetName' => $this->streetName,
69-
'houseNumber' => $this->houseNumber,
70-
'building' => $this->building,
71-
'staircase' => $this->staircase,
72-
'floor' => $this->floor,
73-
'apartment' => $this->apartment,
74-
);
75-
}
76-
7769
}
7870

src/org/nameapi/ontology/input/entities/address/UseForAllAddressRelation.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
*/
1212
class UseForAllAddressRelation extends AddressRelation {
1313

14+
/**
15+
* Used for JSON marshalling only.
16+
*/
17+
public $type = 'UseForAllAddressRelation';
18+
1419
/**
1520
* @var InputAddress $address
1621
*/
@@ -25,31 +30,5 @@ public function __construct(InputAddress $address) {
2530
$this->address = $address;
2631
}
2732

28-
29-
30-
public function jsonSerialize() {
31-
// $x = array(
32-
// '@type' => "UseForAllAddressRelation",
33-
// 'address' => $this->address,
34-
// );
35-
// var_dump($x);
36-
37-
return array(
38-
'type' => "UseForAllAddressRelation",
39-
'address' => $this->address,
40-
);
41-
42-
// $x = array(
43-
// '@type' => "UseForAllAddressRelation",
44-
// 'address' => json_encode($this->address),
45-
// );
46-
// var_dump($x);
47-
48-
// return array(
49-
// '@type' => "UseForAllAddressRelation",
50-
// 'address' => json_encode($this->address),
51-
// );
52-
}
53-
5433
}
5534

src/org/nameapi/ontology/input/entities/contact/EmailAddress.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
namespace org\nameapi\ontology\input\entities\contact;
44

5-
class EmailAddress implements \JsonSerializable {
5+
class EmailAddress {
6+
7+
/**
8+
* Used for JSON marshalling only.
9+
*/
10+
public $type = 'EmailAddressImpl';
611

712
/**
813
* @var string $emailAddress
@@ -16,10 +21,4 @@ public function __construct($emailAddress) {
1621
$this->emailAddress = $emailAddress;
1722
}
1823

19-
public function jsonSerialize() {
20-
return array(
21-
'type' => "EmailAddressImpl",
22-
'emailAddress' => $this->emailAddress,
23-
);
24-
}
2524
}

src/org/nameapi/ontology/input/entities/contact/TelNumber.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
namespace org\nameapi\ontology\input\entities\contact;
44

5-
class TelNumber implements \JsonSerializable {
5+
class TelNumber {
6+
7+
/**
8+
* Used for JSON marshalling only.
9+
*/
10+
public $type = 'SimpleTelNumber';
611

712
/**
813
* @var string $fullNumber
@@ -16,11 +21,4 @@ public function __construct($fullNumber) {
1621
$this->fullNumber = $fullNumber;
1722
}
1823

19-
public function jsonSerialize() {
20-
return array(
21-
'type' => "SimpleTelNumber",
22-
'fullNumber' => $this->fullNumber,
23-
);
24-
}
25-
2624
}

0 commit comments

Comments
 (0)