32 lines
623 B
PHP
32 lines
623 B
PHP
<?php
|
|
|
|
namespace adrienpayet\D2P\data;
|
|
|
|
class Position
|
|
{
|
|
public int $pageIndex;
|
|
public ?float $x = null;
|
|
public ?float $y = null;
|
|
|
|
public function __construct(array $data)
|
|
{
|
|
$this->pageIndex = $data['pageIndex'];
|
|
if (isset($data["x"])) {
|
|
$this->x = (float) $data['x'];
|
|
$this->y = (float) $data['y'];
|
|
}
|
|
}
|
|
|
|
public function toArray() {
|
|
$array = [
|
|
"pageIndex" => $this->pageIndex,
|
|
];
|
|
|
|
if ($this->x) {
|
|
$array["x"] = $this->x;
|
|
$array["y"] = $this->y;
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
}
|