| 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 DisplayedData extends DataObject |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | public $displayedDataType = null; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | public $renderingData = null; |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public $showData = null; |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | public function toObject() |
| 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: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function fromObject($object) |
| 60: | { |
| 61: | parent::fromObject($object); |
| 62: | if (property_exists($object, 'displayedDataType')) { |
| 63: | $this->displayedDataType = $object->displayedDataType; |
| 64: | } |
| 65: | if (property_exists($object, 'renderingData')) { |
| 66: | $this->renderingData = $object->renderingData; |
| 67: | } |
| 68: | if (property_exists($object, 'showData')) { |
| 69: | if (!is_array($object->showData) && !is_object($object->showData)) { |
| 70: | throw new UnexpectedValueException('value \'' . print_r($object->showData, true) . '\' is not an array or object'); |
| 71: | } |
| 72: | $this->showData = []; |
| 73: | foreach ($object->showData as $element) { |
| 74: | $value = new KeyValuePair(); |
| 75: | $this->showData[] = $value->fromObject($element); |
| 76: | } |
| 77: | } |
| 78: | return $this; |
| 79: | } |
| 80: | } |
| 81: | |