1: <?php
2: namespace Worldline\Connect\Sdk\Domain;
3:
4: use UnexpectedValueException;
5:
6: /**
7: * Class ShoppingCartExtension
8: *
9: * @package Worldline\Connect\Sdk\Domain
10: */
11: class ShoppingCartExtension extends DataObject
12: {
13: /**
14: * @var string
15: */
16: public $creator = null;
17:
18: /**
19: * @var string
20: */
21: public $name = null;
22:
23: /**
24: * @var string
25: */
26: public $version = null;
27:
28: /**
29: * @var string
30: */
31: public $extensionId = null;
32:
33: public function __construct($creator, $name, $version, $extensionId = null)
34: {
35: $this->creator = $creator;
36: $this->name = $name;
37: $this->version = $version;
38: $this->extensionId = $extensionId;
39: }
40:
41: /**
42: * @return object
43: */
44: public function toObject()
45: {
46: $object = parent::toObject();
47: if (!is_null($this->creator)) {
48: $object->creator = $this->creator;
49: }
50: if (!is_null($this->name)) {
51: $object->name = $this->name;
52: }
53: if (!is_null($this->version)) {
54: $object->version = $this->version;
55: }
56: if (!is_null($this->extensionId)) {
57: $object->extensionId = $this->extensionId;
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, 'creator')) {
71: $this->creator = $object->creator;
72: }
73: if (property_exists($object, 'name')) {
74: $this->name = $object->name;
75: }
76: if (property_exists($object, 'version')) {
77: $this->version = $object->version;
78: }
79: if (property_exists($object, 'extensionId')) {
80: $this->extensionId = $object->extensionId;
81: }
82: return $this;
83: }
84: }
85: