designtopack/public/site/plugins/classes/Position.php

37 lines
727 B
PHP
Raw Normal View History

<?php
namespace adrienpayet\D2P\data;
class Position
{
2024-12-19 16:03:20 +01:00
public ?int $pageIndex = null;
public ?float $x = null;
public ?float $y = null;
public function __construct(array $data)
{
2024-12-19 16:03:20 +01:00
if (isset($data["pageIndex"])) {
$this->pageIndex = $data['pageIndex'];
}
if (isset($data["x"])) {
$this->x = (float) $data['x'];
$this->y = (float) $data['y'];
}
}
public function toArray() {
2024-12-19 16:03:20 +01:00
$array = [];
if ($this->pageIndex) {
2024-12-19 16:03:20 +01:00
$array["pageIndex"] = $this->pageIndex;
}
if ($this->x) {
$array["x"] = $this->x;
$array["y"] = $this->y;
}
return $array;
}
}