php-kilo/src/Traits/EnumTrait.php

20 lines
300 B
PHP

<?php declare(strict_types=1);
namespace Aviat\Kilo\Traits;
trait EnumTrait {
public function jsonSerialize(): mixed
{
if (property_exists($this, 'value'))
{
return $this->value;
}
if (property_exists($this, 'name'))
{
return $this->name;
}
return print_r($this, true);
}
}