ServerUtil
in package
FinalYes
Tags
Table of Contents
Properties
- $serverRequestFactory : ServerRequestFactoryInterface
- $streamFactory : StreamFactoryInterface
- $uploadedFileFactory : UploadedFileFactoryInterface
- $uriFactory : UriFactoryInterface
Methods
- __construct() : mixed
- createServerRequestFromGlobals() : ServerRequestInterface
- Returns a ServerRequest populated with superglobals: - $_GET - $_POST - $_COOKIE - $_FILES - $_SERVER
- createUploadedFileFromSpec() : UploadedFileInterface|array<string|int, UploadedFileInterface>
- Creates an UploadedFile instance from a $_FILES specification.
- createUriFromGlobals() : UriInterface
- Creates a UriInterface populated with values from $_SERVER.
- normalizeFiles() : array<string, UploadedFileInterface>
- Returns an UploadedFile instance array.
- normalizeNestedFileSpec() : array<string|int, UploadedFileInterface>
- Normalizes an array of file specifications.
- createStreamFromFile() : StreamInterface
Properties
$serverRequestFactory
protected
ServerRequestFactoryInterface
$serverRequestFactory
$streamFactory
protected
StreamFactoryInterface
$streamFactory
$uploadedFileFactory
protected
UploadedFileFactoryInterface
$uploadedFileFactory
$uriFactory
protected
UriFactoryInterface
$uriFactory
Methods
__construct()
public
__construct(ServerRequestFactoryInterface $serverRequestFactory, UriFactoryInterface $uriFactory, UploadedFileFactoryInterface $uploadedFileFactory, StreamFactoryInterface $streamFactory) : mixed
Parameters
- $serverRequestFactory : ServerRequestFactoryInterface
- $uriFactory : UriFactoryInterface
- $uploadedFileFactory : UploadedFileFactoryInterface
- $streamFactory : StreamFactoryInterface
createServerRequestFromGlobals()
Returns a ServerRequest populated with superglobals: - $_GET - $_POST - $_COOKIE - $_FILES - $_SERVER
public
createServerRequestFromGlobals() : ServerRequestInterface
Return values
ServerRequestInterfacecreateUploadedFileFromSpec()
Creates an UploadedFile instance from a $_FILES specification.
public
createUploadedFileFromSpec(array<string|int, mixed> $value) : UploadedFileInterface|array<string|int, UploadedFileInterface>
If the specification represents an array of values, this method will delegate to normalizeNestedFileSpec() and return that return value.
Parameters
- $value : array<string|int, mixed>
Tags
Return values
UploadedFileInterface|array<string|int, UploadedFileInterface>createUriFromGlobals()
Creates a UriInterface populated with values from $_SERVER.
public
createUriFromGlobals() : UriInterface
Return values
UriInterfacenormalizeFiles()
Returns an UploadedFile instance array.
public
normalizeFiles(array<string, string> $files) : array<string, UploadedFileInterface>
Parameters
- $files : array<string, string>
-
An array which respects $_FILES structure
Tags
Return values
array<string, UploadedFileInterface>normalizeNestedFileSpec()
Normalizes an array of file specifications.
public
normalizeNestedFileSpec(array<string|int, mixed> $files) : array<string|int, UploadedFileInterface>
Loops through all nested files and returns a normalized array of UploadedFileInterface instances.
Parameters
- $files : array<string|int, mixed>
Tags
Return values
array<string|int, UploadedFileInterface>createStreamFromFile()
private
createStreamFromFile(string $file) : StreamInterface
Parameters
- $file : string