commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DestinationModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
20 final class DestinationModel extends JsonObjectModel implements Destination
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $type;
28 
33  private static $discriminatorClasses = [
34  'AzureServiceBus' => AzureServiceBusDestinationModel::class,
35  'ConfluentCloud' => ConfluentCloudDestinationModel::class,
36  'EventBridge' => EventBridgeDestinationModel::class,
37  'EventGrid' => AzureEventGridDestinationModel::class,
38  'GoogleCloudPubSub' => GoogleCloudPubSubDestinationModel::class,
39  'SNS' => SnsDestinationModel::class,
40  'SQS' => SqsDestinationModel::class,
41  ];
42 
46  public function __construct(
47  ?string $type = null
48  ) {
49  $this->type = $type;
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 = DestinationModel::class;
98  return $type;
99  }
100 }