commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ZoneUpdateActionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $action;
28 
33  private static $discriminatorClasses = [
34  'addLocation' => ZoneAddLocationActionModel::class,
35  'changeName' => ZoneChangeNameActionModel::class,
36  'removeLocation' => ZoneRemoveLocationActionModel::class,
37  'setDescription' => ZoneSetDescriptionActionModel::class,
38  'setKey' => ZoneSetKeyActionModel::class,
39  ];
40 
44  public function __construct(
45  ?string $action = null
46  ) {
47  $this->action = $action;
48  }
49 
54  public function getAction()
55  {
56  if (is_null($this->action)) {
58  $data = $this->raw(self::FIELD_ACTION);
59  if (is_null($data)) {
60  return null;
61  }
62  $this->action = (string) $data;
63  }
64 
65  return $this->action;
66  }
67 
68 
69 
70 
71 
76  public static function resolveDiscriminatorClass($value): string
77  {
79  if (is_object($value) && isset($value->$fieldName)) {
81  $discriminatorValue = $value->$fieldName;
82  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
83  return self::$discriminatorClasses[$discriminatorValue];
84  }
85  }
86  if (is_array($value) && isset($value[$fieldName])) {
88  $discriminatorValue = $value[$fieldName];
89  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
90  return self::$discriminatorClasses[$discriminatorValue];
91  }
92  }
93 
95  $type = ZoneUpdateActionModel::class;
96  return $type;
97  }
98 }