\Phabstractic\Data\TypesRange

Range - Defines A Range of Values

A range is a predicate that checks if a value is between a minimum and a maximum

CHANGELOG

1.0: Created Range - May 20th, 2013 2.0: Refactored and re-formatted for inclusion in primus - April 11th, 2015 3.0: formatted for inclusion in phabstractic - July 7th, 2016 (exchanged construction arguments)

Summary

Methods
Properties
Constants
getIterator()
__construct()
setMaximum()
setMinimum()
getMaximum()
getMinimum()
isInRange()
__debugInfo()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$max
$min
N/A

Properties

$max

$max : integer

The maximum of the range

Type

integer — Maximum of range

$min

$min : integer

The minimum of the range

Type

integer — Minimum of range

Methods

getIterator()

getIterator() : \ArrayIterator

Instead of \Iterator we use \IteratorAggregate instead

This gets the iterator for the range

Returns

\ArrayIterator —

The iterator for the range

__construct()

__construct(integer  $min, integer  $max) 

The Range Constructor

Takes a maximum, and a minimum, if an argument is missing, defaults to 0

Parameters

integer $min

Minimum range value

integer $max

Maximum range value

Throws

\InvalidArgumentException

if Max and Min are backwards, or are not integers

setMaximum()

setMaximum(integer  $max) 

Sets the maximum of the range

Parameters

integer $max

The given maximum

Throws

\InvalidArgumentException

if max is smaller than $this->min

setMinimum()

setMinimum(integer  $min) 

Sets the minimum of the range

Parameters

integer $min

The given minimum

Throws

\InvalidArgumentException

if min is larger than $this->Max

getMaximum()

getMaximum() : integer

Retrieve range maximum

Returns

integer —

The range maximum

getMinimum()

getMinimum() : integer

Retrieve range minimum

Returns

integer —

The range minimum

isInRange()

isInRange(integer  $x, array  $include = array()) : boolean

Checks to see if an integer is in range.

include array - minimum => true if minimum included maximum => true if maximum included

Parameters

integer $x

The integer to check

array $include

Whether to include the maximum or minimum

Returns

boolean —

Is x in range?

__debugInfo()

__debugInfo() 

Debug Info (var_dump)

Display debug info

Requires PHP 5.6+