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