commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
OrderEditResultModel.php
1<?php
2
3declare(strict_types=1);
10
15use stdClass;
16
21{
22 public const DISCRIMINATOR_VALUE = '';
27 protected $type;
28
33 private static $discriminatorClasses = [
34 'Applied' => OrderEditAppliedModel::class,
35 'NotProcessed' => OrderEditNotProcessedModel::class,
36 'PreviewFailure' => OrderEditPreviewFailureModel::class,
37 'PreviewSuccess' => OrderEditPreviewSuccessModel::class,
38 ];
39
43 public function __construct(
44 ?string $type = null
45 ) {
46 $this->type = $type;
47 }
48
53 public function getType()
54 {
55 if (is_null($this->type)) {
57 $data = $this->raw(self::FIELD_TYPE);
58 if (is_null($data)) {
59 return null;
60 }
61 $this->type = (string) $data;
62 }
63
64 return $this->type;
65 }
66
67
68
69
70
75 public static function resolveDiscriminatorClass($value): string
76 {
78 if (is_object($value) && isset($value->$fieldName)) {
80 $discriminatorValue = $value->$fieldName;
81 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
82 return self::$discriminatorClasses[$discriminatorValue];
83 }
84 }
85 if (is_array($value) && isset($value[$fieldName])) {
87 $discriminatorValue = $value[$fieldName];
88 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
89 return self::$discriminatorClasses[$discriminatorValue];
90 }
91 }
92
94 $type = OrderEditResultModel::class;
95 return $type;
96 }
97}