51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace adrienpayet\D2P\data\location;
|
|
|
|
class Location
|
|
{
|
|
protected PageDetails $page;
|
|
protected ?string $dialogUri = null;
|
|
protected ProjectDetails $project;
|
|
protected ?FileDetails $file = null;
|
|
protected ?string $parentCommentId = null;
|
|
|
|
public function __construct(array $data)
|
|
{
|
|
$this->page = new PageDetails($data["page"]);
|
|
$this->dialogUri = $data["dialogUri"];
|
|
$this->project = new ProjectDetails($data["project"]);
|
|
|
|
if (isset($data['file'])) {
|
|
$this->file = new FileDetails($data["file"]);
|
|
}
|
|
if (isset($data["parentCommentId"])) {
|
|
$this->parentCommentId();
|
|
}
|
|
}
|
|
|
|
public function setParentCommentId($id) {
|
|
$this->parentCommentId = $id;
|
|
}
|
|
|
|
public function parentId() {
|
|
return $this->parentCommentId;
|
|
}
|
|
|
|
public function toArray() {
|
|
$array = [
|
|
"page" => $this->page->toArray(),
|
|
"project" => $this->project->toArray(),
|
|
];
|
|
|
|
if ($this->dialogUri) {
|
|
$array["dialogUri"] = $this->dialogUri;
|
|
}
|
|
|
|
if ($this->file) {
|
|
$array["file"] = $this->file;
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
}
|