Skip to content

Commit 6245461

Browse files
committed
build(codegen): updating SDK
1 parent 9b9354d commit 6245461

File tree

5 files changed

+39
-35
lines changed

5 files changed

+39
-35
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public function getType()
116116
if (is_null($data)) {
117117
return null;
118118
}
119-
$className = AttributeTypeModel::resolveDiscriminatorClass($data);
120-
$this->type = $className::of($data);
119+
120+
$this->type = AttributeTypeModel::of($data);
121121
}
122122

123123
return $this->type;

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

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

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

1919
/**
@@ -22,4 +22,8 @@ interface AttributeType 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/AttributeTypeBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,37 @@
2020
*/
2121
final class AttributeTypeBuilder 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(): AttributeType
2851
{
2952
return new AttributeTypeModel(
53+
$this->name
3054
);
3155
}
3256

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

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
final class AttributeTypeModel extends JsonObjectModel implements AttributeType
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<AttributeType> >
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<AttributeType>
61+
* @param ?string $name
7262
*/
73-
public static function resolveDiscriminatorClass($value): string
63+
public function setName(?string $name): void
7464
{
75-
$fieldName = AttributeType::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<AttributeType> */
92-
$type = AttributeTypeModel::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
@@ -535,3 +535,4 @@ fea3fbfdc8dedcaeb467c0c66bd4968c1d79156c
535535
0eb82a344545c68d83a79ce78e4d353ba3a94a6f
536536
279d1c35e88624bdf58992b694e380fa1e53a85f
537537
18c787052fbe07c50524d8249ada01228db2a8c9
538+
681c61f208c763fb7e0171b337956ebd3773aba1

0 commit comments

Comments
 (0)