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
18: */
19: public $displayHints = null;
20:
21: /**
22: * @var string
23: */
24: public $id = null;
25:
26: /**
27: * @var Installments[]
28: */
29: public $installmentPlans = null;
30:
31: /**
32: * @return object
33: */
34: public function toObject()
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: * @return $this
57: * @throws UnexpectedValueException
58: */
59: public function fromObject($object)
60: {
61: parent::fromObject($object);
62: if (property_exists($object, 'displayHints')) {
63: if (!is_object($object->displayHints)) {
64: throw new UnexpectedValueException('value \'' . print_r($object->displayHints, true) . '\' is not an object');
65: }
66: $value = new InstallmentDisplayHints();
67: $this->displayHints = $value->fromObject($object->displayHints);
68: }
69: if (property_exists($object, 'id')) {
70: $this->id = $object->id;
71: }
72: if (property_exists($object, 'installmentPlans')) {
73: if (!is_array($object->installmentPlans) && !is_object($object->installmentPlans)) {
74: throw new UnexpectedValueException('value \'' . print_r($object->installmentPlans, true) . '\' is not an array or object');
75: }
76: $this->installmentPlans = [];
77: foreach ($object->installmentPlans as $element) {
78: $value = new Installments();
79: $this->installmentPlans[] = $value->fromObject($element);
80: }
81: }
82: return $this;
83: }
84: }
85: