maxlzp/range

Range to be used instead of pair of values

dev-master 2021-02-05 13:46 UTC

This package is auto-updated.

Last update: 2024-05-05 21:00:37 UTC


README

May be used instead of pair of values. More about interval

Installation

Use composer

composer require maxlzp/range

Usage

Create range
$range = Range::between($start, $end);
$range = Range::betweenOpen($start, $end);
$range = Range::betweenLeftOpen($start, $end);
$range = Range::betweenRightOpen($start, $end);
$range = Range::greaterThan($value);
$range = Range::greaterOrEqualThan($value);
$range = Range::lessThan($value);
$range = Range::lessOrEqualThan($value);
Retrieve range properties
$left = $range->getLeft();
$right = $range->getRight();
$isEmpty = $range->isEmpty();
$width = $range->getWidth();
Some features
$gap = $range->gap($otherRange); //Gap between two ranges
$includes = $range->includes($otherRange); //Check if the range includes other range completely
$includesValue = $range->includesValue($value); //Check if the value lays within the range
$split = $range->splitAt($value); //Split the range into two ranges
$touches = $range->touches($otherRange); //Check if ranges are touching one another