designtopack/public/site/plugins/notifications/src/Notification.php
2025-01-15 16:27:08 +01:00

42 lines
1 KiB
PHP

<?php
namespace adrienpayet\notifications;
use adrienpayet\D2P\data\location\Location;
use adrienpayet\D2P\data\Author;
class Notification
{
protected string $type;
protected Location $location;
protected string $text;
protected Author $author;
protected string $date;
protected string $id;
protected array $readby = [];
protected ?Position $position = null;
public function __construct($data) {
$this->type = $data["type"];
$this->location = new Location($data["location"]);
$this->text = $data["text"];
$this->author = new Author($data["author"]);
$this->date = $data["date"];
$this->id = $data["id"];
}
public function toArray() {
$array = [
"type" => $this->type,
"location" => $this->location->toArray(),
"text" => $this->text,
"author" => $this->author->toArray(),
"date" => $this->date,
"id" => $this->id,
"readby" => $this->readby,
];
return $array;
}
}