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 PaymentProductFilter extends DataObject
15: {
16: /**
17: * @var string[]|null
18: */
19: public ?array $groups = null;
20:
21: /**
22: * @var int[]|null
23: */
24: public ?array $products = null;
25:
26: /**
27: * @return object
28: */
29: public function toObject(): object
30: {
31: $object = parent::toObject();
32: if (!is_null($this->groups)) {
33: $object->groups = [];
34: foreach ($this->groups as $element) {
35: if (!is_null($element)) {
36: $object->groups[] = $element;
37: }
38: }
39: }
40: if (!is_null($this->products)) {
41: $object->products = [];
42: foreach ($this->products as $element) {
43: if (!is_null($element)) {
44: $object->products[] = $element;
45: }
46: }
47: }
48: return $object;
49: }
50:
51: /**
52: * @param object $object
53: *
54: * @return $this
55: * @throws UnexpectedValueException
56: */
57: public function fromObject(object $object): PaymentProductFilter
58: {
59: parent::fromObject($object);
60: if (property_exists($object, 'groups')) {
61: if (!is_array($object->groups) && !is_object($object->groups)) {
62: throw new UnexpectedValueException('value \'' . print_r($object->groups, true) . '\' is not an array or object');
63: }
64: $this->groups = [];
65: foreach ($object->groups as $element) {
66: $this->groups[] = $element;
67: }
68: }
69: if (property_exists($object, 'products')) {
70: if (!is_array($object->products) && !is_object($object->products)) {
71: throw new UnexpectedValueException('value \'' . print_r($object->products, true) . '\' is not an array or object');
72: }
73: $this->products = [];
74: foreach ($object->products as $element) {
75: $this->products[] = $element;
76: }
77: }
78: return $this;
79: }
80: }
81: