src/Helper/Path.php
protected function normalizePathComponents(): array
    {
        $components = [];

        // fetch key of first and last item
        $keys = array_keys($this->components);
        $positionStart = reset($keys);
        $positionEnd = end($keys);

        // iterate through all path-components
        foreach ($this->components as $position => $component) {

            // parse single path-component
            $path = self::normalize($component, $position === $positionStart, $position === $positionEnd);

            // normalize path
            $path = str_replace(['/', '\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $path);

            if ($position === $positionStart && $path === DIRECTORY_SEPARATOR) {
                $components[] = DIRECTORY_SEPARATOR;
            } elseif ($position === $positionStart) {
                $components[] = rtrim($path, DIRECTORY_SEPARATOR);
            } else {
                $components[] = trim($path, DIRECTORY_SEPARATOR);
            }
        }

        return $components;
    }
protected function normalizePathComponents(): array
    {
        $components = [];

        // fetch key of first and last item
        $keys = array_keys($this->components);
        $positionStart = reset($keys);
        $positionEnd = end($keys);

        // iterate through all path-components
        foreach ($this->components as $position => $component) {

            // parse single path-component
            $path = self::normalize($component, $position === $positionStart, $position === $positionEnd);

            // normalize path
            $path = str_replace(['/', '\\', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR, $path);

            if ($position === $positionStart && $path === DIRECTORY_SEPARATOR) {
                $components[] = DIRECTORY_SEPARATOR;
            } elseif ($position === $positionStart) {
                $components[] = rtrim($path, DIRECTORY_SEPARATOR);
            } else {
                $components[] = trim($path, DIRECTORY_SEPARATOR);
            }
        }

        return $components;
    }
protected function normalizePathComponents ( ) : array { $ components = [ ] ; // fetch key of first and last item $ keys = array_keys ( $ this -> components ) ; $ positionStart = reset ( $ keys ) ; $ positionEnd = end ( $ keys ) ; // iterate through all path-components foreach ( $ this -> components as $ position => $ component ) { // parse single path-component $ path = self :: normalize ( $ component , $ position === $ positionStart , $ position === $ positionEnd ) ; // normalize path $ path = str_replace ( [ '/' , '\\' , DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ] , DIRECTORY_SEPARATOR , $ path ) ; if ( $ position === $ positionStart && $ path === DIRECTORY_SEPARATOR ) { $ components [ ] = DIRECTORY_SEPARATOR ; } elseif ( $ position === $ positionStart ) { $ components [ ] = rtrim ( $ path , DIRECTORY_SEPARATOR ) ; } else { $ components [ ] = trim ( $ path , DIRECTORY_SEPARATOR ) ; } } return $ components ; }
parse each path-component and extract path-info
@return string[]
@throws UnexpectedValueException
parse each path - component and extract path - info