54 lines
1.3 KiB
PHP

<?php
/**
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @license MIT
*/
declare(strict_types=1);
namespace MyPrayerJournal\Domain;
use BitBadger\InspiredByFSharp\Option;
use Square\Pjson\{Json, JsonSerialize};
/**
* A record of an action taken on a request
*/
class History
{
use JsonSerialize;
/** @var string The date/time this entry was made */
#[Json]
public string $asOf = '';
/** @var RequestAction The action taken for this history entry */
#[Json]
public RequestAction $action;
/** @var string|null The text for this history entry (optional) */
#[Json('text', omit_empty: true)]
private ?string $dbText {
get => $this->text->unwrap();
set { $this->text = Option::of($value); }
}
/** @var Option<string> The text for this history entry */
public Option $text {
get => $this->text ?? Option::None();
set { $this->text = $value; }
}
/**
* @param string $asOf The date/time this entry was made
* @param RequestAction $action The action taken for this history entry
* @param string|null $text The text for this history entry (optional)
*/
public function __construct(string $asOf, RequestAction $action, ?string $text = null)
{
$this->asOf = $asOf;
$this->action = $action;
$this->dbText = $text;
}
}