Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to array method in mustache templates and assert it's faster #625

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AccountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -1205,6 +1205,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AcctInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -1136,6 +1136,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AchDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -756,6 +756,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalData3DSecure.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -582,6 +582,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalDataAirline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -1290,6 +1290,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalDataCarRental.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -1117,6 +1117,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalDataCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -912,6 +912,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalDataLevel23.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -913,6 +913,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
28 changes: 27 additions & 1 deletion src/Adyen/Model/Checkout/AdditionalDataLodging.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* The version of the OpenAPI document: 71
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 6.0.1
* OpenAPI Generator version: 6.4.0
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand Down Expand Up @@ -879,6 +879,32 @@ public function jsonSerialize()
return ObjectSerializer::sanitizeForSerialization($this);
}

public function toArray(): array
{
$array = [];
foreach (self::$openAPITypes as $propertyName => $propertyType) {
$propertyValue = $this[$propertyName];
if ($propertyValue !== null) {
// Check if the property value is an object and has a toArray() method
if (is_object($propertyValue) && method_exists($propertyValue, 'toArray')) {
$array[$propertyName] = $propertyValue->toArray();
// Check if it's type datetime
} elseif ($propertyValue instanceof \DateTime) {
$array[$propertyName] = $propertyValue->format(DATE_ATOM);
// If it's an array type we should check whether it contains objects and if so call toArray method
} elseif (is_array($propertyValue)) {
$array[$propertyName] = array_map(function ($item) {
return $item instanceof ModelInterface ? $item->toArray() : $item;
}, $propertyValue);
} else {
// Otherwise, directly assign the property value to the array
$array[$propertyName] = $propertyValue;
}
}
}
return $array;
}

/**
* Gets the string presentation of the object
*
Expand Down
Loading
Loading