com\setasign\SetaFramework\Helper

FilesystemHelper Class FilesystemHelper

File: /SetaFramework/src/Helper/FilesystemHelper.php

Class hierarchy

Summary

Static Methods

chmod()

public static FilesystemHelper::chmod (
string $filename,
int $permissions
): void

Change file permission. This method ignores the umask!

Parameters
$filename: string
 
$permissions: int
 
Exceptions

Throws \com\setasign\SetaFramework\Exception

cleanupPath()

public static FilesystemHelper::cleanupPath (
string $path
): string

Resolves '..' in paths without relying on the existance of the path like realpath(). This method will not remove ".." at the beginning of the string.

DIRECTORY_SEPARATOR at the end of the string will be replaced

The input path and the output path should technically be the same.

Parameters
$path: string
 

createResponseByFile()

public static FilesystemHelper::createResponseByFile (
\com\setasign\SetaFramework\Http\HttpFactoryInterface $httpFactory,
\com\setasign\SetaFramework\FileSystem\File $file,
bool $inline = true,
array $headers = array ( )
): \Psr\Http\Message\ResponseInterface

Creates a response by a file

Parameters
$httpFactory: \com\setasign\SetaFramework\Http\HttpFactoryInterface
 
$file: \com\setasign\SetaFramework\FileSystem\File
 
$inline: bool

If true then the content-disposition is set to inline otherwise to attachment

$headers: array

Additional HttpHeaders Content-Type, Content-Length and Content-Disposition cannot be used

Exceptions

Throws \com\setasign\SetaFramework\FileSystem\ReadException

dirIsEmpty()

public static FilesystemHelper::dirIsEmpty (
string $path
): bool
Parameters
$path: string
 

encodeFilenameForHttpHeader()

protected static FilesystemHelper::encodeFilenameForHttpHeader (
$filename
): string
Parameters
$filename
 

getMaxFileUploadSize()

public static FilesystemHelper::getMaxFileUploadSize (
void
): float

getReadableFileSize()

public static FilesystemHelper::getReadableFileSize (
float $bytes,
int $precision = 2
): string
Parameters
$bytes: float
 
$precision: int
 

getReadableMaxFileUploadSize()

public static FilesystemHelper::getReadableMaxFileUploadSize (
int $precision = 0
): string
Parameters
$precision: int
 

md5Files()

public static FilesystemHelper::md5Files (
iterable $files
): string
Parameters
$files: iterable
 

mkdir()

public static FilesystemHelper::mkdir (
string $dirName,
int $permission = 509,
bool $recursive = true
): void

Create a directory. This method ignores the umask!

Parameters
$dirName: string
 
$permission: int
 
$recursive: bool
 
Exceptions

Throws \com\setasign\SetaFramework\Exception

parseSize()

private static FilesystemHelper::parseSize (
string $size
): float
Parameters
$size: string
 

readDirectoryRecursive()

public static FilesystemHelper::readDirectoryRecursive (
string $dir,
bool $includeFiles = true,
bool $includeDirectories = true
): array

Reads the directory recursivly.

Note: The file order may differ on different OS.

Parameters
$dir: string
 
$includeFiles: bool
 
$includeDirectories: bool
 

readDirectoryRecursiveAsGenerator()

public static FilesystemHelper::readDirectoryRecursiveAsGenerator (
string $dir,
bool $includeFiles = true,
bool $includeDirectories = true
): \Generator

Reads the directory recursivly.

Note: The file order may differ on different OS.

Parameters
$dir: string
 
$includeFiles: bool
 
$includeDirectories: bool
 

recursiveGlob()

WARNING: This method is marked as deprecated!

Use readDirectoryRecursive() instead. This method ignores

public static FilesystemHelper::recursiveGlob (
string $pattern,
int $flags = 0
): array
Parameters
$pattern: string
 
$flags: int
 

recursiveGlobAsGenerator()

WARNING: This method is marked as deprecated!

Use readDirectoryRecursiveAsGenerator() instead.

public static FilesystemHelper::recursiveGlobAsGenerator (
string $pattern,
int $flags = 0
): \Generator
Parameters
$pattern: string
 
$flags: int
 

unlinkRecursive()

public static FilesystemHelper::unlinkRecursive (
string $dir,
bool $includeDirectory = false
): void

Removes the content from the directory.

Parameters
$dir: string
 
$includeDirectory: bool