Skip to content

Commit fa48fa5

Browse files
committed
build(codegen): updating SDK
1 parent d7ffd97 commit fa48fa5

File tree

5 files changed

+39
-35
lines changed

5 files changed

+39
-35
lines changed

lib/commercetools-history/src/Models/Common/FieldDefinitionModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function getType()
8484
if (is_null($data)) {
8585
return null;
8686
}
87-
$className = FieldTypeModel::resolveDiscriminatorClass($data);
88-
$this->type = $className::of($data);
87+
88+
$this->type = FieldTypeModel::of($data);
8989
}
9090

9191
return $this->type;

lib/commercetools-history/src/Models/Common/FieldType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
interface FieldType extends JsonObject
1515
{
16-
public const DISCRIMINATOR_FIELD = 'name';
16+
1717
public const FIELD_NAME = 'name';
1818

1919
/**
@@ -22,4 +22,8 @@ interface FieldType extends JsonObject
2222
*/
2323
public function getName();
2424

25+
/**
26+
* @param ?string $name
27+
*/
28+
public function setName(?string $name): void;
2529
}

lib/commercetools-history/src/Models/Common/FieldTypeBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,37 @@
2020
*/
2121
final class FieldTypeBuilder implements Builder
2222
{
23+
/**
2324
25+
* @var ?string
26+
*/
27+
private $name;
2428

29+
/**
30+
31+
* @return null|string
32+
*/
33+
public function getName()
34+
{
35+
return $this->name;
36+
}
37+
38+
/**
39+
* @param ?string $name
40+
* @return $this
41+
*/
42+
public function withName(?string $name)
43+
{
44+
$this->name = $name;
45+
46+
return $this;
47+
}
2548

2649

2750
public function build(): FieldType
2851
{
2952
return new FieldTypeModel(
53+
$this->name
3054
);
3155
}
3256

lib/commercetools-history/src/Models/Common/FieldTypeModel.php

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
final class FieldTypeModel extends JsonObjectModel implements FieldType
2121
{
2222

23-
public const DISCRIMINATOR_VALUE = '';
23+
2424
/**
2525
*
2626
* @var ?string
2727
*/
2828
protected $name;
2929

30-
/**
31-
* @psalm-var array<string, class-string<FieldType> >
32-
*
33-
*/
34-
private static $discriminatorClasses = [
35-
];
3630

3731
/**
3832
* @psalm-suppress MissingParamType
@@ -63,33 +57,14 @@ public function getName()
6357
}
6458

6559

66-
67-
68-
6960
/**
70-
* @psalm-param stdClass|array<string, mixed> $value
71-
* @psalm-return class-string<FieldType>
61+
* @param ?string $name
7262
*/
73-
public static function resolveDiscriminatorClass($value): string
63+
public function setName(?string $name): void
7464
{
75-
$fieldName = FieldType::DISCRIMINATOR_FIELD;
76-
if (is_object($value) && isset($value->$fieldName)) {
77-
/** @psalm-var string $discriminatorValue */
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])) {
84-
/** @psalm-var string $discriminatorValue */
85-
$discriminatorValue = $value[$fieldName];
86-
if (isset(self::$discriminatorClasses[$discriminatorValue])) {
87-
return self::$discriminatorClasses[$discriminatorValue];
88-
}
89-
}
90-
91-
/** @psalm-var class-string<FieldType> */
92-
$type = FieldTypeModel::class;
93-
return $type;
65+
$this->name = $name;
9466
}
67+
68+
69+
9570
}

references.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,4 @@ fea3fbfdc8dedcaeb467c0c66bd4968c1d79156c
537537
18c787052fbe07c50524d8249ada01228db2a8c9
538538
681c61f208c763fb7e0171b337956ebd3773aba1
539539
7fe613ca616e3dc91ba35bb3a8109ff1a4ec534a
540+
f3c35b1b92ccc332f0b95003f0f22ea8f0e5f8e0

0 commit comments

Comments
 (0)