commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
HttpDestinationAuthenticationModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $type;
28 
33  private static $discriminatorClasses = [
34  'AuthorizationHeader' => AuthorizationHeaderAuthenticationModel::class,
35  'AzureFunctions' => AzureFunctionsAuthenticationModel::class,
36  ];
37 
41  public function __construct(
42  ?string $type = null
43  ) {
44  $this->type = $type;
45  }
46 
51  public function getType()
52  {
53  if (is_null($this->type)) {
55  $data = $this->raw(self::FIELD_TYPE);
56  if (is_null($data)) {
57  return null;
58  }
59  $this->type = (string) $data;
60  }
61 
62  return $this->type;
63  }
64 
65 
66 
67 
68 
73  public static function resolveDiscriminatorClass($value): string
74  {
76  if (is_object($value) && isset($value->$fieldName)) {
78  $discriminatorValue = $value->$fieldName;
79  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
80  return self::$discriminatorClasses[$discriminatorValue];
81  }
82  }
83  if (is_array($value) && isset($value[$fieldName])) {
85  $discriminatorValue = $value[$fieldName];
86  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
87  return self::$discriminatorClasses[$discriminatorValue];
88  }
89  }
90 
92  $type = HttpDestinationAuthenticationModel::class;
93  return $type;
94  }
95 }