public function testNumericRangeInclusiveIteration()
 {
     $expected = array(10, 12, 14, 16, 18, 20);
     $range = new NumericRangeInclusive(10, 20, 2);
     foreach ($range->iterable() as $value) {
         $this->assertEquals(array_shift($expected), $value);
     }
     $this->assertEquals(0, count($expected));
 }
示例#2
0
 /**
  * @param int $start
  * @param int $end
  * @throws InvalidArgumentException
  * @throws InvalidRangeException
  */
 public function __construct($start, $end)
 {
     if (!is_int($start)) {
         throw new InvalidArgumentException();
     }
     if (!is_int($end)) {
         throw new InvalidArgumentException();
     }
     if ($start > $end) {
         throw new InvalidRangeException();
     }
     parent::__construct($start, $end, 1);
 }