Skip to content

Commit

Permalink
add to array method in mustache templates and assert it's faster than…
Browse files Browse the repository at this point in the history
… json parsing
  • Loading branch information
jillingk committed Feb 19, 2024
1 parent 148e0ad commit 1e75b28
Show file tree
Hide file tree
Showing 195 changed files with 5,092 additions and 4,896 deletions.
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

0 comments on commit 1e75b28

Please sign in to comment.