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