Get configuration file nesting path.

@param SplFileInfo $file
@param string      $path

@return string
420374
protected function getNestedDirectory(SplFileInfo $file, $path)
    {
        $directory = $file->getPath();

        if ($nested = trim(str_replace($path, '', $directory), DIRECTORY_SEPARATOR)) {
            $nested = str_replace(DIRECTORY_SEPARATOR, '.', $nested).'.';
        }

        return $nested;
    }
133985
public function create(\SplFileInfo $file)
    {
        $extension = $file->getExtension();
        switch ($extension) {
            case 'css':
                return new StylesheetDocument();
            case 'js':
                return new JavascriptDocument();
            default:
                if (strstr($this->getMimeType($file), 'image')) {
                    return new ImageDocument();
                }

                return new FileDocument();
        }
    }
770203
public function resolve($file)
    {
        $info = null;

        $this->rewind();
        foreach (clone $this as $path) {
            $info = new SplFileInfo(rtrim($path, '/') . '/' . ltrim($file, '/'));

            if ($info->isDir() || $info->isFile() || $info->isLink()) {
                break;
            }
        }

        return ($info)? $info->getPathname() : null;
    }
812788
public static function find($paths, $file)
    {
        // Force to array
        if (!is_array($paths) && !($paths instanceof \Iterator))
        {
            settype($paths, 'array');
        }

        // Start looping through the path set
        foreach ($paths as $path)
        {
            // Get the path to the file
            $fullname = $path . '/' . $file;

            // Is the path based on a stream?
            if (strpos($path, '://') === false)
            {
                // Not a stream, so do a realpath() to avoid directory
                // traversal attempts on the local file system.

                $pathFile = new \SplFileInfo($path);
                $fullnameFile = new \SplFileInfo($fullname);

                $path = $pathFile->getPathInfo()->getPathname();
                $fullname = $fullnameFile->getPathInfo()->getPathname();

                if ($path !== false) {
                    $path .= DIRECTORY_SEPARATOR . $pathFile->getFilename();
                }

                if ($fullname !== false) {
                    $fullname .= DIRECTORY_SEPARATOR . $fullnameFile->getFilename();
                }
            }

            /*
             * The substr() check added to make sure that the realpath()
             * results in a directory registered so that
             * non-registered directories are not accessible via directory
             * traversal attempts.
             */
            if (file_exists($fullname) && substr($fullname, 0, strlen($path)) == $path)
            {
                return $fullname;
            }
        }

        // Could not find the file in the set of paths
        return false;
    }
197861
private function getFileContents(SplFileInfo $file)
    {
        $content = $file->getContents();
        if ($file->getExtension() === 'js' && substr($content, -1) !== ';') {
            $content .= ';';
        }

        return $content;
    }
218289
protected function loadConfigurationFile(array $configuration, SplFileInfo $file, $key = null)
    {
        $pathname = $file->getPathname();
        $contents = $this->loader->load($pathname);
        $contents = mb_strpos($key, 'plugins') === false ? $this->wrapConfigurationContents($file, $contents) : $contents;
        if (!is_array($contents)) {
            return $configuration;
        }

        // Since non-PHP files don't support closures
        // unset them to pass configuration validation
        if ($file->getExtension() !== 'php') {
            unset($contents['config']['logs'], $contents['remote']['permissions']['callback']);
        }

        // Append configuration to the queue
        $configuration[$pathname] = [];
        Arr::set($configuration[$pathname], $key, $contents);

        return $configuration;
    }
836371
public static function createFromSplFileInfo(\SplFileInfo $file)
    {
        $asset = new Asset();
        $guesser = MimeTypeGuesser::getInstance();
        return $asset
            ->setFilename($file->getFilename())
            ->setExtension($file->getExtension())
            ->setPathname($file->getPathname())
            ->setMimeType($guesser->guess($file->getPathname()))
            ->setClientOriginalName($file->getFilename())
            ->setClientOriginalExtension($file->getExtension())
        ;
    }
581053
public function clean(SplFileInfo $file)
    {
        $name = $file->getFilename();
        if ($file->isFile()) {
            $name = pathinfo($name, PATHINFO_FILENAME);
        }

        $name = str_replace("\t\n\r\0\x0B", ' ', $name); // remove control characters
        $name = str_replace('_', ' ', $name);

        $name = preg_replace('/\[[^\[\]]*\]/', ' ', $name); // remove [...]
        $name = preg_replace('/\([^\(\)]*\)/', ' ', $name); // remove (...)

        // remove all file meta data
        $reg = sprintf('/[ .,](?:%s)[ .,]/i', implode('|', $this->meta));
        while (preg_match($reg, $name.' ')) {
            $name = preg_replace($reg, ' ', $name.' ');
        }

        $name = str_replace('  ', ' ', $name); // remove double spaces
        $name = trim($name, ' .,-');

        return $name;
    }
1113978
private function getReflectionClassFromFile(SplFileInfo $file)
    {
        $namespace = null;
        if (preg_match('#^namespace\s+(.+?);$#sm', $file->getContents(), $matches)) {
            $namespace = $matches[1];
        }

        $controller = null;
        if ($namespace) {
            $name = substr($file->getRelativePathname(), 0, -4);
            $controller = sprintf('%s\\%s', $namespace, $name);
        }

        if ($controller) {
            return new \ReflectionClass($controller);
        }

        throw new RuntimeException(sprintf('File "%s" is not contain any class.', $file->getFilename()));
    }
664181
protected function parse(\SplFileInfo $file): array
    {
        $config = require_once $file->getRealPath();

        if (!is_array($config)) {
            throw new ConfigurationParseException('Invalid configuration file');
        }

        return $config;
    }
126436
protected function getFullClassFromFile(\SplFileInfo $fileInfo)
    {
        $contents = file_get_contents($fileInfo->getRealPath());
        $matches = array();

        preg_match('#class +([A-Za-z]+) +implements#i', $contents, $matches);

        if (isset($matches[1])) {
            $className = $matches[1];

            $matches = array();
            preg_match('#namespace +([A-Za-z\\\\]+);#i', $contents, $matches);
            $namespace = $matches[1];

            return $namespace . '\\' . $className;
        } else {
            return null;
        }
    }
549580
protected function getMetaFilePath($file)
	{
		$parts = pathinfo($file);
		$metaFilename = sprintf($this->metaFileMask, $parts['basename']);
		return str_replace($parts['basename'], $metaFilename, $file);
	}
1149141
protected function getFilePath($path, $file)
    {
        if (!is_string($file)) {
            $file   = ".env";
        }

        return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
    }
65596
public static function rpath(String $file = NULL) : String
    {
        $config = Config::get('Filesystem', 'file', self::$access);

        self::$access = NULL;

        if( $config['parentDirectoryAccess'] === false )
        {
            $file = str_replace('../', '', $file);
        }

        if( $config['realPath'] === true )
        {
            $file = Base::prefix(self::originpath($file), REAL_BASE_DIR);
        }

        return $file;
    }
928228
protected function parse(\SplFileInfo $file): array
    {
        $config = json_decode(file_get_contents($file->getRealPath()), true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new ConfigurationParseException('Unable to parse json file: ' . json_last_error_msg());
        }

        return $config;
    }
492624
protected function normalizeFileInfo(SplFileInfo $file)
    {
        if (! $file->isLink()) {
            $normalized = [
                'type'      => $file->getType(),
                'path'      => $this->getFilePath($file),
                'timestamp' => $file->getMTime()
            ];

            if ($normalized['type'] === 'file') {
                $normalized['size'] = $file->getSize();
            }

            return $normalized;
        }
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }