commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ChangeTargetChangeValueModel.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 'customLineItems' => ChangeTargetCustomLineItemsChangeValueModel::class,
36 'lineItems' => ChangeTargetLineItemsChangeValueModel::class,
37 'multiBuyCustomLineItems' => ChangeTargetMultiBuyCustomLineItemsChangeValueModel::class,
38 'multiBuyLineItems' => ChangeTargetMultiBuyLineItemsChangeValueModel::class,
39 'pattern' => ChangeTargetPatternChangeValueModel::class,
40 'shipping' => ChangeTargetShippingChangeValueModel::class,
41 ];
42
46 public function __construct(
47 ?string $type = null
48 ) {
49 $this->type = $type;
50
51 }
52
57 public function getType()
58 {
59 if (is_null($this->type)) {
61 $data = $this->raw(self::FIELD_TYPE);
62 if (is_null($data)) {
63 return null;
64 }
65 $this->type = (string) $data;
66 }
67
68 return $this->type;
69 }
70
71
72
73
74
79 public static function resolveDiscriminatorClass($value): string
80 {
82 if (is_object($value) && isset($value->$fieldName)) {
84 $discriminatorValue = $value->$fieldName;
85 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
86 return self::$discriminatorClasses[$discriminatorValue];
87 }
88 }
89 if (is_array($value) && isset($value[$fieldName])) {
91 $discriminatorValue = $value[$fieldName];
92 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
93 return self::$discriminatorClasses[$discriminatorValue];
94 }
95 }
96
98 $type = ChangeTargetChangeValueModel::class;
99 return $type;
100 }
101}