Noherczeg\Breadcrumb\Breadcrumb::segment PHP Method

segment() public method

segment: A getter which returns the Segment which is at the given position.
public segment ( String $id ) : Segment
$id String The ID of the required Segment.
return Segment
    public function segment($id)
    {
        if (in_array($id, array_keys($this->segments))) {
            return $this->segments[$id];
        } else {
            throw new OutOfRangeException("Invalid argument provided, no segment is present with id: {$id}!");
        }
    }

Usage Example

コード例 #1
0
 /**
  * @Test
  */
 public function testRemoveWithReorder()
 {
     $this->bread->append('one');
     $this->bread->append('two');
     $this->bread->remove(0, true);
     $this->assertEquals('two', $this->bread->segment(0)->get('raw'));
 }