<?php
 declare(strict_types=1); namespace Square\Models; use stdClass; class CashPaymentDetails implements \JsonSerializable { private $buyerSuppliedMoney; private $changeBackMoney; public function __construct(Money $buyerSuppliedMoney) { $this->buyerSuppliedMoney = $buyerSuppliedMoney; } public function getBuyerSuppliedMoney(): Money { return $this->buyerSuppliedMoney; } public function setBuyerSuppliedMoney(Money $buyerSuppliedMoney): void { $this->buyerSuppliedMoney = $buyerSuppliedMoney; } public function getChangeBackMoney(): ?Money { return $this->changeBackMoney; } public function setChangeBackMoney(?Money $changeBackMoney): void { $this->changeBackMoney = $changeBackMoney; } #[\ReturnTypeWillChange] public function jsonSerialize(bool $asArrayWhenEmpty = false) { $json = []; $json['buyer_supplied_money'] = $this->buyerSuppliedMoney; if (isset($this->changeBackMoney)) { $json['change_back_money'] = $this->changeBackMoney; } $json = array_filter($json, function ($val) { return $val !== null; }); return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; } } 