RequestContext
in package
Holds information about the current request.
This class implements a fluent interface.
Tags
Table of Contents
- $baseUrl : mixed
- $host : mixed
- $httpPort : mixed
- $httpsPort : mixed
- $method : mixed
- $parameters : mixed
- $pathInfo : mixed
- $queryString : mixed
- $scheme : mixed
- __construct() : mixed
- fromRequest() : $this
- Updates the RequestContext information based on a HttpFoundation Request.
- fromUri() : self
- getBaseUrl() : string
- Gets the base URL.
- getHost() : string
- Gets the HTTP host.
- getHttpPort() : int
- Gets the HTTP port.
- getHttpsPort() : int
- Gets the HTTPS port.
- getMethod() : string
- Gets the HTTP method.
- getParameter() : mixed
- Gets a parameter value.
- getParameters() : array<string|int, mixed>
- Returns the parameters.
- getPathInfo() : string
- Gets the path info.
- getQueryString() : string
- Gets the query string without the "?".
- getScheme() : string
- Gets the HTTP scheme.
- hasParameter() : bool
- Checks if a parameter value is set for the given parameter.
- isSecure() : bool
- setBaseUrl() : $this
- Sets the base URL.
- setHost() : $this
- Sets the HTTP host.
- setHttpPort() : $this
- Sets the HTTP port.
- setHttpsPort() : $this
- Sets the HTTPS port.
- setMethod() : $this
- Sets the HTTP method.
- setParameter() : $this
- Sets a parameter value.
- setParameters() : $this
- Sets the parameters.
- setPathInfo() : $this
- Sets the path info.
- setQueryString() : $this
- Sets the query string.
- setScheme() : $this
- Sets the HTTP scheme.
Properties
$baseUrl
private
mixed
$baseUrl
$host
private
mixed
$host
$httpPort
private
mixed
$httpPort
$httpsPort
private
mixed
$httpsPort
$method
private
mixed
$method
$parameters
private
mixed
$parameters
= []
$pathInfo
private
mixed
$pathInfo
$queryString
private
mixed
$queryString
$scheme
private
mixed
$scheme
Methods
__construct()
public
__construct([string $baseUrl = '' ][, string $method = 'GET' ][, string $host = 'localhost' ][, string $scheme = 'http' ][, int $httpPort = 80 ][, int $httpsPort = 443 ][, string $path = '/' ][, string $queryString = '' ]) : mixed
Parameters
- $baseUrl : string = ''
- $method : string = 'GET'
- $host : string = 'localhost'
- $scheme : string = 'http'
- $httpPort : int = 80
- $httpsPort : int = 443
- $path : string = '/'
- $queryString : string = ''
Return values
mixed —fromRequest()
Updates the RequestContext information based on a HttpFoundation Request.
public
fromRequest(Request $request) : $this
Parameters
- $request : Request
Return values
$this —fromUri()
public
static fromUri(string $uri[, string $host = 'localhost' ][, string $scheme = 'http' ][, int $httpPort = 80 ][, int $httpsPort = 443 ]) : self
Parameters
- $uri : string
- $host : string = 'localhost'
- $scheme : string = 'http'
- $httpPort : int = 80
- $httpsPort : int = 443
Return values
self —getBaseUrl()
Gets the base URL.
public
getBaseUrl() : string
Return values
string —getHost()
Gets the HTTP host.
public
getHost() : string
The host is always lowercased because it must be treated case-insensitive.
Return values
string —getHttpPort()
Gets the HTTP port.
public
getHttpPort() : int
Return values
int —getHttpsPort()
Gets the HTTPS port.
public
getHttpsPort() : int
Return values
int —getMethod()
Gets the HTTP method.
public
getMethod() : string
The method is always an uppercased string.
Return values
string —getParameter()
Gets a parameter value.
public
getParameter(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getParameters()
Returns the parameters.
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPathInfo()
Gets the path info.
public
getPathInfo() : string
Return values
string —getQueryString()
Gets the query string without the "?".
public
getQueryString() : string
Return values
string —getScheme()
Gets the HTTP scheme.
public
getScheme() : string
Return values
string —hasParameter()
Checks if a parameter value is set for the given parameter.
public
hasParameter(string $name) : bool
Parameters
- $name : string
Return values
bool —isSecure()
public
isSecure() : bool
Return values
bool —setBaseUrl()
Sets the base URL.
public
setBaseUrl(string $baseUrl) : $this
Parameters
- $baseUrl : string
Return values
$this —setHost()
Sets the HTTP host.
public
setHost(string $host) : $this
Parameters
- $host : string
Return values
$this —setHttpPort()
Sets the HTTP port.
public
setHttpPort(int $httpPort) : $this
Parameters
- $httpPort : int
Return values
$this —setHttpsPort()
Sets the HTTPS port.
public
setHttpsPort(int $httpsPort) : $this
Parameters
- $httpsPort : int
Return values
$this —setMethod()
Sets the HTTP method.
public
setMethod(string $method) : $this
Parameters
- $method : string
Return values
$this —setParameter()
Sets a parameter value.
public
setParameter(string $name, mixed $parameter) : $this
Parameters
- $name : string
- $parameter : mixed
-
The parameter value
Return values
$this —setParameters()
Sets the parameters.
public
setParameters(array<string|int, mixed> $parameters) : $this
Parameters
- $parameters : array<string|int, mixed>
-
The parameters
Return values
$this —setPathInfo()
Sets the path info.
public
setPathInfo(string $pathInfo) : $this
Parameters
- $pathInfo : string
Return values
$this —setQueryString()
Sets the query string.
public
setQueryString(string|null $queryString) : $this
Parameters
- $queryString : string|null
Return values
$this —setScheme()
Sets the HTTP scheme.
public
setScheme(string $scheme) : $this
Parameters
- $scheme : string