public function parent($condition = null)
    {
        // Up one level
        if (null === $condition) {
            array_pop($this->paths);
        } elseif (is_int($condition)) {
            // Up mutiple level
            $this->paths = array_slice($this->paths, 0, -$condition);
        } elseif (is_string($condition)) {
            // Find a dir name and go to this level
            $paths = $this->paths;

            $paths = array_reverse($paths);

            // Find parent
            $n = 0;

            foreach ($paths as $key => $name) {
                if ($key == 0) {
                    // Ignore latest dir
                    continue;
                }

                // Is this dir match condition?
                if ($name == $condition) {
                    $n = $key;
                    break;
                }
            }

            $this->paths = array_slice($this->paths, 0, -$n);
        }

        return $this;
    }
public function parent($condition = null)
    {
        // Up one level
        if (null === $condition) {
            array_pop($this->paths);
        } elseif (is_int($condition)) {
            // Up mutiple level
            $this->paths = array_slice($this->paths, 0, -$condition);
        } elseif (is_string($condition)) {
            // Find a dir name and go to this level
            $paths = $this->paths;

            $paths = array_reverse($paths);

            // Find parent
            $n = 0;

            foreach ($paths as $key => $name) {
                if ($key == 0) {
                    // Ignore latest dir
                    continue;
                }

                // Is this dir match condition?
                if ($name == $condition) {
                    $n = $key;
                    break;
                }
            }

            $this->paths = array_slice($this->paths, 0, -$n);
        }

        return $this;
    }
public function parent ( $ condition = null ) { // Up one level if ( null === $ condition ) { array_pop ( $ this -> paths ) ; } elseif ( is_int ( $ condition ) ) { // Up mutiple level $ this -> paths = array_slice ( $ this -> paths , 0 , - $ condition ) ; } elseif ( is_string ( $ condition ) ) { // Find a dir name and go to this level $ paths = $ this -> paths ; $ paths = array_reverse ( $ paths ) ; // Find parent $ n = 0 ; foreach ( $ paths as $ key => $ name ) { if ( $ key == 0 ) { // Ignore latest dir continue ; } // Is this dir match condition? if ( $ name == $ condition ) { $ n = $ key ; break ; } } $ this -> paths = array_slice ( $ this -> paths , 0 , - $ n ) ; } return $ this ; }
Get a parent path of given condition.

@param   bool|int|string $condition Parent condition.

@return  static  Return this object to support chaining.

@since  2.0
Get a parent path of given condition .