2024-12-18 13:56:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-12-18 15:05:42 +01:00
|
|
|
namespace adrienpayet\D2P\data;
|
2024-12-18 13:56:21 +01:00
|
|
|
|
|
|
|
|
class Position
|
|
|
|
|
{
|
2024-12-19 16:03:20 +01:00
|
|
|
public ?int $pageIndex = null;
|
2024-12-18 18:22:41 +01:00
|
|
|
public ?float $x = null;
|
|
|
|
|
public ?float $y = null;
|
2024-12-18 13:56:21 +01:00
|
|
|
|
|
|
|
|
public function __construct(array $data)
|
|
|
|
|
{
|
2024-12-19 16:03:20 +01:00
|
|
|
if (isset($data["pageIndex"])) {
|
|
|
|
|
$this->pageIndex = $data['pageIndex'];
|
|
|
|
|
}
|
2024-12-18 18:22:41 +01:00
|
|
|
if (isset($data["x"])) {
|
|
|
|
|
$this->x = (float) $data['x'];
|
|
|
|
|
$this->y = (float) $data['y'];
|
|
|
|
|
}
|
2024-12-18 13:56:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toArray() {
|
2024-12-19 16:03:20 +01:00
|
|
|
$array = [];
|
|
|
|
|
|
2025-01-28 09:37:33 +01:00
|
|
|
if (isset($this->pageIndex)) {
|
2024-12-19 16:03:20 +01:00
|
|
|
$array["pageIndex"] = $this->pageIndex;
|
|
|
|
|
}
|
2024-12-18 18:22:41 +01:00
|
|
|
|
|
|
|
|
if ($this->x) {
|
|
|
|
|
$array["x"] = $this->x;
|
|
|
|
|
$array["y"] = $this->y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $array;
|
2024-12-18 13:56:21 +01:00
|
|
|
}
|
|
|
|
|
}
|