commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ChangeValueChangeValueModel.php
1<?php
2
3declare(strict_types=1);
10
15use stdClass;
16
21{
22
23 public const DISCRIMINATOR_VALUE = '';
28 protected $type;
29
34 private static $discriminatorClasses = [
35 'absolute' => ChangeValueAbsoluteChangeValueModel::class,
36 'external' => ChangeValueExternalChangeValueModel::class,
37 'giftLineItem' => ChangeValueGiftLineItemChangeValueModel::class,
38 'relative' => ChangeValueRelativeChangeValueModel::class,
39 ];
40
44 public function __construct(
45 ?string $type = null
46 ) {
47 $this->type = $type;
48
49 }
50
55 public function getType()
56 {
57 if (is_null($this->type)) {
59 $data = $this->raw(self::FIELD_TYPE);
60 if (is_null($data)) {
61 return null;
62 }
63 $this->type = (string) $data;
64 }
65
66 return $this->type;
67 }
68
69
70
71
72
77 public static function resolveDiscriminatorClass($value): string
78 {
80 if (is_object($value) && isset($value->$fieldName)) {
82 $discriminatorValue = $value->$fieldName;
83 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
84 return self::$discriminatorClasses[$discriminatorValue];
85 }
86 }
87 if (is_array($value) && isset($value[$fieldName])) {
89 $discriminatorValue = $value[$fieldName];
90 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
91 return self::$discriminatorClasses[$discriminatorValue];
92 }
93 }
94
96 $type = ChangeValueChangeValueModel::class;
97 return $type;
98 }
99}