1: <?php
2: /*
3: * This class was auto-generated from the API references found at
4: * https://apireference.connect.worldline-solutions.com/
5: */
6: namespace Worldline\Connect\Sdk\V1\Domain;
7:
8: use UnexpectedValueException;
9: use Worldline\Connect\Sdk\Domain\DataObject;
10:
11: /**
12: * @package Worldline\Connect\Sdk\V1\Domain
13: */
14: class PaymentProducts extends DataObject
15: {
16: /**
17: * @var PaymentProduct[]|null
18: */
19: public ?array $paymentProducts = null;
20:
21: /**
22: * @return object
23: */
24: public function toObject(): object
25: {
26: $object = parent::toObject();
27: if (!is_null($this->paymentProducts)) {
28: $object->paymentProducts = [];
29: foreach ($this->paymentProducts as $element) {
30: if (!is_null($element)) {
31: $object->paymentProducts[] = $element->toObject();
32: }
33: }
34: }
35: return $object;
36: }
37:
38: /**
39: * @param object $object
40: *
41: * @return $this
42: * @throws UnexpectedValueException
43: */
44: public function fromObject(object $object): PaymentProducts
45: {
46: parent::fromObject($object);
47: if (property_exists($object, 'paymentProducts')) {
48: if (!is_array($object->paymentProducts) && !is_object($object->paymentProducts)) {
49: throw new UnexpectedValueException('value \'' . print_r($object->paymentProducts, true) . '\' is not an array or object');
50: }
51: $this->paymentProducts = [];
52: foreach ($object->paymentProducts as $element) {
53: $value = new PaymentProduct();
54: $this->paymentProducts[] = $value->fromObject($element);
55: }
56: }
57: return $this;
58: }
59: }
60: