protected function checkSlice(Slice $slice) { if ($slice->getFinish() > $this->getLength() || $slice->getStart() < 0) { throw new \OutOfBoundsException(sprintf('the slice %s is outside the length %d of this line.', $slice, $this->getLength())); } }