index = $index; $this->start = $start; $this->end = $end; } // ----------------------------------------------------------------------------------------------------------------- /** * @return mixed */ public function getIndex() { return $this->index; } /** * @return mixed */ public function getStart() { return $this->start; } /** * @return mixed */ public function getEnd() { return $this->end; } public function getLength() { return $this->end - $this->start; } // ----------------------------------------------------------------------------------------------------------------- public function intersectionBegin($start, $length) { if($start < $this->start) { return $this->start; } return $start - $this->start; } public function intersectionEnd($start, $length) { if(($start + $length) > $this->end) { return $this->getLength(); } return $length; } public function contains($start, $length) { if($start >= $this->start) { if($start <= ($this->end)) { return true; } } return false; } public function fullyContains($start, $length) { if($start >= $this->start) { if(($start + $length) <= ($this->end)) { return true; } } return false; } }