src/Path.php
public function slice($offset, $length = null)
	{
		if (is_numeric($offset) && is_int(+$offset)) {
			if ($length === null || (is_numeric($length) && is_int(+$length))) {
				$this->segments = array_slice($this->segments, $offset, $length);
			} else {
				throw new \InvalidArgumentException(
					__METHOD__."() expects parameter two, length, to be null or an integer"
				);
			}
		} else {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, offset, to be an integer"
			);
		}
		
		return $this;
	}
public function slice($offset, $length = null)
	{
		if (is_numeric($offset) && is_int(+$offset)) {
			if ($length === null || (is_numeric($length) && is_int(+$length))) {
				$this->segments = array_slice($this->segments, $offset, $length);
			} else {
				throw new \InvalidArgumentException(
					__METHOD__."() expects parameter two, length, to be null or an integer"
				);
			}
		} else {
			throw new \InvalidArgumentException(
				__METHOD__."() expects parameter one, offset, to be an integer"
			);
		}
		
		return $this;
	}
public function slice ( $ offset , $ length = null ) { if ( is_numeric ( $ offset ) && is_int ( + $ offset ) ) { if ( $ length === null || ( is_numeric ( $ length ) && is_int ( + $ length ) ) ) { $ this -> segments = array_slice ( $ this -> segments , $ offset , $ length ) ; } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter two, length, to be null or an integer" ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, offset, to be an integer" ) ; } return $ this ; }
Slices the path

Keep in mind, I will change this path. To keep this path the same and return a
new, sliced Path, use the getSlice() method instead.

For example:

$path = new Path('foo/bar/baz');
$path->slice(1);

echo $path;  // prints "bar/baz"

@param  int  $offset  if offset is non-negative, the slice will start at that
offset from the beginning of the path; if offset is negative, the slice
will start that far from the end of the path
@param  int  $length  if length is given and positive, the slice will have up
to that many segments in it; if the path is shorter than length, then only
the available segments will be present; if length is given and negative,
the slice will stop that many segments from the end of the path; finally,
if length is omitted, the slice will have everything from the offset to the
end of the path (optional; if omitted, defaults to null)
@return  self
@throws  InvalidArgumentException  if $offset is not an integer
@throws  InvalidArgumentException  if $length is not null or an integer
@since   0.1.0
Slices the path