exampleapp/modules/Tasks/Dto/TaskTrait.php

33 lines
648 B
PHP

<?php
namespace Modules\Tasks\Dto;
trait TaskTrait
{
protected ?string $id = null;
protected ?string $title = null;
protected ?int $createdAt = null;
protected array $options = [];
public function getId(): ?string
{
return $this->id;
}
public function load(array $data): void
{
$this->id = $data['id'] ?? null;
$this->title = $data['title'] ?? null;
$this->createdAt = $data['created_at'] ?? null;
if (key_exists('options', $data)) {
$this->loadOptions($data['options']);
}
}
abstract public function loadOptions(array $data): void;
}