for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Src\UseCases\Domain\Shared\Model;
abstract class Dto implements \JsonSerializable
{
public function jsonSerialize()
return $this->serialize(get_object_vars($this));
}
private function serialize(array $properties)
foreach ($properties as $key => $property){
if(is_object($property)){
$params[$this->camelToSnake($key)] = $this->serialize(get_object_vars($property));
}else {
$params[$this->camelToSnake($key)] = $property;
return $params;
$params
foreach
16
private function camelToSnake($input)
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input));
public function toArray():array