66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
// phpcs:disable PEAR.Commenting.FileComment,PEAR.Commenting.ClassComment
|
|
|
|
/**
|
|
* Task domain model.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace IronKanban\Domain;
|
|
|
|
/**
|
|
* Represents a task on the board.
|
|
*/
|
|
final class Task
|
|
{
|
|
/**
|
|
* Create a task instance.
|
|
*
|
|
* @param string $id Task identifier.
|
|
* @param string $title Task title.
|
|
* @param string $projectId Owning project identifier.
|
|
* @param string $column Column identifier.
|
|
* @param int $order Sort order within the column.
|
|
* @param bool $completed Completion flag.
|
|
* @param string $priority Priority label.
|
|
* @param bool $isActive Active state flag.
|
|
* @param string $body Markdown body.
|
|
* @param array<string, mixed> $meta Additional task metadata.
|
|
*/
|
|
public function __construct(
|
|
public string $id,
|
|
public string $title,
|
|
public string $projectId,
|
|
public string $column,
|
|
public int $order,
|
|
public bool $completed,
|
|
public string $priority,
|
|
public bool $isActive,
|
|
public string $body,
|
|
public array $meta = []
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Convert the task into an API-friendly array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'project_id' => $this->projectId,
|
|
'column' => $this->column,
|
|
'order' => $this->order,
|
|
'completed' => $this->completed,
|
|
'priority' => $this->priority,
|
|
'is_active' => $this->isActive,
|
|
'body' => $this->body,
|
|
'meta' => $this->meta,
|
|
];
|
|
}
|
|
}
|