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