Example #1
0
 public function testMutators()
 {
     $base = ['b', 'c', 'd'];
     $arr = new ArrayObject($base);
     $arr->push('e', 'f');
     $this->assertEquals(['b', 'c', 'd', 'e', 'f'], $arr->toArray());
     $this->assertEquals('f', $arr->pop());
     $this->assertEquals('e', $arr->pop());
     $arr->prepend('a');
     $this->assertEquals(['a', 'b', 'c', 'd'], $arr->toArray());
     $this->assertEquals('a', $arr->shift());
     $this->assertEquals($base, $arr->toArray());
 }
Example #2
0
 /**
  * Returns a copy of this path truncated after the given number of segments.
  * 
  * @param int $count
  * @return Path
  */
 public function upToSegment($count)
 {
     $segments = new ArrayObject();
     for ($i = 0; $i < $count; $i++) {
         $segments->push($this->segments[$i]);
     }
     return new Path($segments->join('/'));
 }