src/FileInfo.php
public static function fromPath($path, $as = '')
    {
        clearstatcache(false, $path);

        if (!file_exists($path)) {
            throw new FileInfoException("$path does not exist");
        }

        $stat = stat($path);
        $file = new FileInfo();

        $file->setPath($path);
        $file->setIsdir(is_dir($path));
        $file->setMode(fileperms($path));
        $file->setOwner(fileowner($path));
        $file->setGroup(filegroup($path));
        $file->setSize(filesize($path));
        $file->setUid($stat['uid']);
        $file->setGid($stat['gid']);
        $file->setMtime($stat['mtime']);

        if ($as) {
            $file->setPath($as);
        }

        return $file;
    }
public static function fromPath($path, $as = '')
    {
        clearstatcache(false, $path);

        if (!file_exists($path)) {
            throw new FileInfoException("$path does not exist");
        }

        $stat = stat($path);
        $file = new FileInfo();

        $file->setPath($path);
        $file->setIsdir(is_dir($path));
        $file->setMode(fileperms($path));
        $file->setOwner(fileowner($path));
        $file->setGroup(filegroup($path));
        $file->setSize(filesize($path));
        $file->setUid($stat['uid']);
        $file->setGid($stat['gid']);
        $file->setMtime($stat['mtime']);

        if ($as) {
            $file->setPath($as);
        }

        return $file;
    }
public static function fromPath ( $ path , $ as = '' ) { clearstatcache ( false , $ path ) ; if ( ! file_exists ( $ path ) ) { throw new FileInfoException ( "$path does not exist" ) ; } $ stat = stat ( $ path ) ; $ file = new FileInfo ( ) ; $ file -> setPath ( $ path ) ; $ file -> setIsdir ( is_dir ( $ path ) ) ; $ file -> setMode ( fileperms ( $ path ) ) ; $ file -> setOwner ( fileowner ( $ path ) ) ; $ file -> setGroup ( filegroup ( $ path ) ) ; $ file -> setSize ( filesize ( $ path ) ) ; $ file -> setUid ( $ stat [ 'uid' ] ) ; $ file -> setGid ( $ stat [ 'gid' ] ) ; $ file -> setMtime ( $ stat [ 'mtime' ] ) ; if ( $ as ) { $ file -> setPath ( $ as ) ; } return $ file ; }
Factory to build FileInfo from existing file or directory

@param string $path path to a file on the local file system
@param string $as   optional path to use inside the archive
@throws FileInfoException
@return FileInfo
Factory to build FileInfo from existing file or directory