1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | namespace Worldline\Connect\Sdk\V1\Domain; |
7: | |
8: | use UnexpectedValueException; |
9: | use Worldline\Connect\Sdk\Domain\DataObject; |
10: | |
11: | |
12: | |
13: | |
14: | class PaymentProductFilter extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $groups = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $products = null; |
25: | |
26: | |
27: | |
28: | |
29: | public function toObject() |
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: | |
53: | |
54: | |
55: | |
56: | public function fromObject($object) |
57: | { |
58: | parent::fromObject($object); |
59: | if (property_exists($object, 'groups')) { |
60: | if (!is_array($object->groups) && !is_object($object->groups)) { |
61: | throw new UnexpectedValueException('value \'' . print_r($object->groups, true) . '\' is not an array or object'); |
62: | } |
63: | $this->groups = []; |
64: | foreach ($object->groups as $element) { |
65: | $this->groups[] = $element; |
66: | } |
67: | } |
68: | if (property_exists($object, 'products')) { |
69: | if (!is_array($object->products) && !is_object($object->products)) { |
70: | throw new UnexpectedValueException('value \'' . print_r($object->products, true) . '\' is not an array or object'); |
71: | } |
72: | $this->products = []; |
73: | foreach ($object->products as $element) { |
74: | $this->products[] = $element; |
75: | } |
76: | } |
77: | return $this; |
78: | } |
79: | } |
80: | |