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
|
|
|
|
|
{
|
|
|
|
|
public int $pageIndex;
|
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)
|
|
|
|
|
{
|
|
|
|
|
$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-18 18:22:41 +01:00
|
|
|
$array = [
|
2024-12-18 13:56:21 +01:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
}
|