29 private int $firstSector;
31 private int $sectorCount;
32 private int $timestamp;
37 public function __construct(
int $firstSector,
int $sectorCount,
int $timestamp){
38 if($firstSector < 0 || $firstSector >= 2 ** 24){
39 throw new \InvalidArgumentException(
"Start sector must be positive, got $firstSector");
41 $this->firstSector = $firstSector;
43 throw new \InvalidArgumentException(
"Sector count must be positive, got $sectorCount");
45 $this->sectorCount = $sectorCount;
46 $this->timestamp = $timestamp;
49 public function getFirstSector() : int{
50 return $this->firstSector;
53 public function getLastSector() : int{
54 return $this->firstSector + $this->sectorCount - 1;
62 return range($this->getFirstSector(), $this->getLastSector());
69 return $this->sectorCount;
72 public function getTimestamp() : int{
73 return $this->timestamp;
76 public function overlaps(RegionLocationTableEntry $other) : bool{
77 $overlapCheck = static function(RegionLocationTableEntry $entry1, RegionLocationTableEntry $entry2) : bool{
78 $entry1Last = $entry1->getLastSector();
79 $entry2Last = $entry2->getLastSector();
82 ($entry2->firstSector >= $entry1->firstSector && $entry2->firstSector <= $entry1Last) ||
83 ($entry2Last >= $entry1->firstSector && $entry2Last <= $entry1Last)
86 return $overlapCheck($this, $other) || $overlapCheck($other, $this);