2024-10-30 09:49:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace adrienpayet\comments;
|
2024-12-18 16:26:55 +01:00
|
|
|
use adrienpayet\D2P\data\location\Location;
|
|
|
|
|
use adrienpayet\D2P\data\Author;
|
2024-12-18 18:22:41 +01:00
|
|
|
use adrienpayet\D2P\data\Position;
|
2024-10-30 09:49:16 +01:00
|
|
|
|
|
|
|
|
class BaseComment {
|
2024-12-18 16:26:55 +01:00
|
|
|
protected Location $location;
|
|
|
|
|
protected Author $author;
|
2024-12-18 18:22:41 +01:00
|
|
|
protected string $text;
|
2024-12-18 16:26:55 +01:00
|
|
|
protected string $date;
|
|
|
|
|
protected string $id;
|
2024-12-20 12:36:21 +01:00
|
|
|
protected ?Position $position = null;
|
2024-10-30 09:49:16 +01:00
|
|
|
|
|
|
|
|
public function __construct($data) {
|
2024-12-18 15:05:42 +01:00
|
|
|
$this->location = new Location($data["location"]);
|
|
|
|
|
$this->text = $data["text"];
|
|
|
|
|
$this->author = new Author($data["author"]);
|
|
|
|
|
$this->date = $data["date"];
|
|
|
|
|
$this->id = $data["id"];
|
2024-12-18 18:22:41 +01:00
|
|
|
$this->position = new Position($data['position']);
|
2024-11-18 09:36:15 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-30 09:49:16 +01:00
|
|
|
public function toArray() {
|
|
|
|
|
return [
|
2024-12-18 16:26:55 +01:00
|
|
|
"location" => $this->location->toArray(),
|
2024-12-18 18:22:41 +01:00
|
|
|
"position" => $this->position->toArray(),
|
2024-12-18 16:26:55 +01:00
|
|
|
"text" => $this->text,
|
|
|
|
|
"author" => $this->author->toArray(),
|
|
|
|
|
"date" => $this->date,
|
|
|
|
|
"id" => $this->id,
|
2024-10-30 09:49:16 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|