Exemplo n.º 1
0
 public function testConstruct()
 {
     $err = new \r8\Exception\Index(5, 'Array Offset', 'Out of bounds', 219);
     $this->assertEquals("Out of bounds", $err->getMessage());
     $this->assertEquals(219, $err->getCode());
     $this->assertEquals(array("Index Label" => "Array Offset", 'Value' => "int(5)"), $err->getData());
 }
Exemplo n.º 2
0
 /**
  * Constructor...
  *
  * @param Integer $offset The offset at which to start iteration
  * @param \Traversable $inner The iterator being wrapped
  */
 public function __construct($offset, \Traversable $inner)
 {
     $this->inner = $inner;
     $offset = (int) $offset;
     // If we can, be intelligent about the offset
     if ($inner instanceof \Countable) {
         try {
             $offset = \r8\num\offsetWrap($inner->count(), $offset, \r8\num\OFFSET_NONE);
         } catch (\r8\Exception\Index $err) {
             $offset = NULL;
         }
     } else {
         if ($offset < 0) {
             $err = new \r8\Exception\Index($offset, "Iterator Offset", "Negative offsets are only supported if Iterator implements the Countable interface");
             $err->addData("Iterator", \r8\getDump($inner));
             throw $err;
         }
     }
     $this->offset = $offset;
 }