for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SimpleCMS\DynamicUnit\Packages;
class AttributeModel implements \JsonSerializable
{
protected ?string $thumbnail = null;
public function __construct(public int $id, public string $name, public string $value, array $thumbnail = [])
if (!empty($thumbnail)) {
$this->thumbnail = $thumbnail['url'];
}
/**
* toArray
* @return array<string,null|string>>
*/
public function toArray(): array
$data = [
'id' => $this->id ?? 0,
'name' => $this->name ?? null,
'value' => $this->value ?? null,
'thumbnail' => $this->thumbnail ?? null
];
return $data;
* jsonSerialize
* @return mixed
public function jsonSerialize()
return $this->toArray();
* __toString
* @return string
public function __toString(): string
return json_encode($this->toArray());