charitable
/
vendor
/
square
/
square
/
src
/
Legacy
/
Models
/
DeviceComponentDetailsNetworkInterfaceDetails.php
DeviceComponentDetailsNetworkInterfaceDetails.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13.1, at vendor/square/square/src/Legacy/Models/DeviceComponentDetailsNetworkInterfaceDetails.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Square\Legacy\Models; |
| 6 | |
| 7 | use stdClass; |
| 8 | |
| 9 | class DeviceComponentDetailsNetworkInterfaceDetails implements \JsonSerializable |
| 10 | { |
| 11 | /** |
| 12 | * @var array |
| 13 | */ |
| 14 | private $ipAddressV4 = []; |
| 15 | |
| 16 | /** |
| 17 | * Returns Ip Address V4. |
| 18 | * The string representation of the device’s IPv4 address. |
| 19 | */ |
| 20 | public function getIpAddressV4(): ?string |
| 21 | { |
| 22 | if (count($this->ipAddressV4) == 0) { |
| 23 | return null; |
| 24 | } |
| 25 | return $this->ipAddressV4['value']; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Sets Ip Address V4. |
| 30 | * The string representation of the device’s IPv4 address. |
| 31 | * |
| 32 | * @maps ip_address_v4 |
| 33 | */ |
| 34 | public function setIpAddressV4(?string $ipAddressV4): void |
| 35 | { |
| 36 | $this->ipAddressV4['value'] = $ipAddressV4; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Unsets Ip Address V4. |
| 41 | * The string representation of the device’s IPv4 address. |
| 42 | */ |
| 43 | public function unsetIpAddressV4(): void |
| 44 | { |
| 45 | $this->ipAddressV4 = []; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Encode this object to JSON |
| 50 | * |
| 51 | * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 52 | * are set. (default: false) |
| 53 | * |
| 54 | * @return array|stdClass |
| 55 | */ |
| 56 | #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 57 | public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 58 | { |
| 59 | $json = []; |
| 60 | if (!empty($this->ipAddressV4)) { |
| 61 | $json['ip_address_v4'] = $this->ipAddressV4['value']; |
| 62 | } |
| 63 | $json = array_filter($json, function ($val) { |
| 64 | return $val !== null; |
| 65 | }); |
| 66 | |
| 67 | return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 68 | } |
| 69 | } |
| 70 |