commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ChangeTargetChangeValueModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use 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  'shipping' => ChangeTargetShippingChangeValueModel::class,
40  ];
41 
45  public function __construct(
46  ?string $type = null
47  ) {
48  $this->type = $type;
49 
50  }
51 
56  public function getType()
57  {
58  if (is_null($this->type)) {
60  $data = $this->raw(self::FIELD_TYPE);
61  if (is_null($data)) {
62  return null;
63  }
64  $this->type = (string) $data;
65  }
66 
67  return $this->type;
68  }
69 
70 
71 
72 
73 
78  public static function resolveDiscriminatorClass($value): string
79  {
81  if (is_object($value) && isset($value->$fieldName)) {
83  $discriminatorValue = $value->$fieldName;
84  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
85  return self::$discriminatorClasses[$discriminatorValue];
86  }
87  }
88  if (is_array($value) && isset($value[$fieldName])) {
90  $discriminatorValue = $value[$fieldName];
91  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
92  return self::$discriminatorClasses[$discriminatorValue];
93  }
94  }
95 
97  $type = ChangeTargetChangeValueModel::class;
98  return $type;
99  }
100 }