ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Data\Range Class Reference

A simple class to express a naive range of whole positive numbers. More...

+ Collaboration diagram for ILIAS\Data\Range:

Public Member Functions

 __construct (int $start, int $length)
 
 unpack ()
 
 getStart ()
 
 getLength ()
 
 getEnd ()
 
 withStart (int $start)
 
 withLength (int $length)
 

Protected Member Functions

 checkStart (int $start)
 
 checkLength (int $length)
 

Protected Attributes

 $start
 
 $length
 

Detailed Description

A simple class to express a naive range of whole positive numbers.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

Definition at line 10 of file Range.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Range::__construct ( int  $start,
int  $length 
)

Definition at line 23 of file Range.php.

References ILIAS\Data\Range\$length, ILIAS\Data\Range\$start, ILIAS\Data\Range\checkLength(), and ILIAS\Data\Range\checkStart().

24  {
25  $this->checkStart($start);
26  $this->checkLength($length);
27  $this->start = $start;
28  $this->length = $length;
29  }
checkLength(int $length)
Definition: Range.php:38
checkStart(int $start)
Definition: Range.php:31
+ Here is the call graph for this function:

Member Function Documentation

◆ checkLength()

ILIAS\Data\Range::checkLength ( int  $length)
protected

Definition at line 38 of file Range.php.

Referenced by ILIAS\Data\Range\__construct(), and ILIAS\Data\Range\withLength().

39  {
40  if ($length < 1) {
41  throw new \InvalidArgumentException("Length must be larger than 1", 1);
42  }
43  }
+ Here is the caller graph for this function:

◆ checkStart()

ILIAS\Data\Range::checkStart ( int  $start)
protected

Definition at line 31 of file Range.php.

Referenced by ILIAS\Data\Range\__construct(), and ILIAS\Data\Range\withStart().

32  {
33  if ($start < 0) {
34  throw new \InvalidArgumentException("Start must be a positive number (or 0)", 1);
35  }
36  }
+ Here is the caller graph for this function:

◆ getEnd()

ILIAS\Data\Range::getEnd ( )

Definition at line 60 of file Range.php.

References ILIAS\Data\Range\$length.

Referenced by RangeTest\testEndCalculation(), RangeTest\testWithLength(), and RangeTest\testWithStart().

60  : int
61  {
62  return $this->start + $this->length;
63  }
+ Here is the caller graph for this function:

◆ getLength()

ILIAS\Data\Range::getLength ( )

Definition at line 55 of file Range.php.

References ILIAS\Data\Range\$length.

Referenced by RangeTest\testValues(), RangeTest\testWithLength(), and RangeTest\testWithStart().

55  : int
56  {
57  return $this->length;
58  }
+ Here is the caller graph for this function:

◆ getStart()

ILIAS\Data\Range::getStart ( )

Definition at line 50 of file Range.php.

References ILIAS\Data\Range\$start.

Referenced by RangeTest\testValues(), RangeTest\testWithLength(), and RangeTest\testWithStart().

50  : int
51  {
52  return $this->start;
53  }
+ Here is the caller graph for this function:

◆ unpack()

ILIAS\Data\Range::unpack ( )

Definition at line 45 of file Range.php.

References ILIAS\Data\Range\$length, and ILIAS\Data\Range\$start.

Referenced by RangeTest\testUnpack().

45  : array
46  {
47  return [$this->start, $this->length];
48  }
+ Here is the caller graph for this function:

◆ withLength()

ILIAS\Data\Range::withLength ( int  $length)

Definition at line 73 of file Range.php.

References ILIAS\Data\Range\$length, and ILIAS\Data\Range\checkLength().

Referenced by RangeTest\testNegativeLength(), RangeTest\testNullLength(), and RangeTest\testWithLength().

73  : Range
74  {
75  $this->checkLength($length);
76  $clone = clone $this;
77  $clone->length = $length;
78  return $clone;
79  }
checkLength(int $length)
Definition: Range.php:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withStart()

ILIAS\Data\Range::withStart ( int  $start)

Definition at line 65 of file Range.php.

References ILIAS\Data\Range\$start, and ILIAS\Data\Range\checkStart().

Referenced by RangeTest\testNegativeStart(), and RangeTest\testWithStart().

65  : Range
66  {
67  $this->checkStart($start);
68  $clone = clone $this;
69  $clone->start = $start;
70  return $clone;
71  }
checkStart(int $start)
Definition: Range.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $length

◆ $start

ILIAS\Data\Range::$start
protected

The documentation for this class was generated from the following file: