feat: add deserilazation

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-03 21:33:28 -04:00
parent 8f61c4d2d5
commit fe78426a5d
4 changed files with 41 additions and 2 deletions
+18
View File
@@ -15,6 +15,24 @@ class RangeTally extends Range implements IRangeTally {
protected string|int $position = 0;
protected int $tally = 32;
public function jsonDeserialize(array|string $data): static {
if (is_string($data)) {
$data = json_decode($data, true, flags: JSON_THROW_ON_ERROR);
}
if (isset($data['anchor'])) {
$this->setAnchor(RangeAnchorType::from($data['anchor']));
}
if (isset($data['position'])) {
$this->setPosition($data['position']);
}
if (isset($data['tally'])) {
$this->setTally($data['tally']);
}
return $this;
}
/**
* Returns the type of the range
*