Skip to content

Commit 8ad3fbb

Browse files
authored
Merge pull request #103 from OttiaDevsPT/PP6-125
Update Customer class to allow nullable networkAddress and countryCod…
2 parents 1810367 + c913d49 commit 8ad3fbb

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/Model/Token/Customer.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,46 @@ public function validate()
4141
return true;
4242
}
4343

44-
/** @var string $networkAddress */
44+
/** @var string|null $networkAddress */
4545
protected $networkAddress;
4646

47-
/** @var string $countryCode */
47+
/** @var string|null $countryCode */
4848
protected $countryCode;
4949

5050
/**
51-
* @param string $networkAddress
51+
* @param string|null $networkAddress
5252
* @return Customer
5353
*/
54-
public function setNetworkAddress(string $networkAddress): Customer
54+
public function setNetworkAddress(?string $networkAddress): Customer
5555
{
5656
$this->networkAddress = $networkAddress;
5757

5858
return $this;
5959
}
6060

6161
/**
62-
* @return string
62+
* @return string|null
6363
*/
64-
public function getNetworkAddress(): string
64+
public function getNetworkAddress(): ?string
6565
{
6666
return $this->networkAddress;
6767
}
6868

6969
/**
70-
* @param string $countryCode
70+
* @param string|null $countryCode
7171
* @return Customer
7272
*/
73-
public function setCountryCode(string $countryCode): Customer
73+
public function setCountryCode(?string $countryCode): Customer
7474
{
7575
$this->countryCode = $countryCode;
7676

7777
return $this;
7878
}
7979

8080
/**
81-
* @return string
81+
* @return string|null
8282
*/
83-
public function getCountryCode(): string
83+
public function getCountryCode(): ?string
8484
{
8585
return $this->countryCode;
8686
}
@@ -103,8 +103,13 @@ public function jsonSerialize(): array
103103
*/
104104
public function loadFromStdClass(\stdClass $customer): Customer
105105
{
106-
$this->setNetworkAddress($customer->network_address);
107-
$this->setCountryCode($customer->country_code);
106+
if (isset($customer->network_address)) {
107+
$this->setNetworkAddress($customer->network_address);
108+
}
109+
110+
if (isset($customer->country_code)) {
111+
$this->setCountryCode($customer->country_code);
112+
}
108113

109114
return $this;
110115
}

0 commit comments

Comments
 (0)