Request
in package
Request
parses request parameters and provides helper functions for routing
Table of Contents
Constants
- MIME_HTML = 'text/html'
- MIME type for HTML
- MIME_JSON = 'application/json'
- MIME type for JSON
- MIME_XHTML = 'application/xhtml+xml'
- MIME type for XHTML
Properties
- $_inputStream : string
- Input stream to use for PUT parameter parsing
- $_isJsonApi : bool
- If we are in a JSON API context
- $_operation : string
- Operation to perform
- $_params : array<string|int, mixed>
- Request parameters
Methods
- __construct() : mixed
- Constructor
- getData() : array<string|int, mixed>
- Get data of paste or comment
- getHost() : string
- Get host as requested by the client
- getOperation() : string
- Get current operation
- getParam() : string
- Get a request parameter
- getRequestUri() : string
- Get request URI
- isJsonApiCall() : bool
- If we are in a JSON API context
- setInputStream() : mixed
- Override the default input stream source, used for unit testing
- _detectJsonRequest() : bool
- Detect the clients supported media type and decide if its a JSON API call or not
- getPasteId() : string
- Return the paste ID of the current paste.
Constants
MIME_HTML
MIME type for HTML
public
mixed
MIME_HTML
= 'text/html'
Tags
MIME_JSON
MIME type for JSON
public
mixed
MIME_JSON
= 'application/json'
Tags
MIME_XHTML
MIME type for XHTML
public
mixed
MIME_XHTML
= 'application/xhtml+xml'
Tags
Properties
$_inputStream
Input stream to use for PUT parameter parsing
private
static string
$_inputStream
= 'php://input'
Tags
$_isJsonApi
If we are in a JSON API context
private
bool
$_isJsonApi
= false
Tags
$_operation
Operation to perform
private
string
$_operation
= 'view'
Tags
$_params
Request parameters
private
array<string|int, mixed>
$_params
= array()
Tags
Methods
__construct()
Constructor
public
__construct() : mixed
Tags
getData()
Get data of paste or comment
public
getData() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getHost()
Get host as requested by the client
public
getHost() : string
Tags
Return values
stringgetOperation()
Get current operation
public
getOperation() : string
Tags
Return values
stringgetParam()
Get a request parameter
public
getParam(string $param[, string $default = '' ]) : string
Parameters
- $param : string
- $default : string = ''
Tags
Return values
stringgetRequestUri()
Get request URI
public
getRequestUri() : string
Tags
Return values
stringisJsonApiCall()
If we are in a JSON API context
public
isJsonApiCall() : bool
Tags
Return values
boolsetInputStream()
Override the default input stream source, used for unit testing
public
static setInputStream(string $input) : mixed
Parameters
- $input : string
_detectJsonRequest()
Detect the clients supported media type and decide if its a JSON API call or not
private
_detectJsonRequest() : bool
Adapted from: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php#3771447
Tags
Return values
boolgetPasteId()
Return the paste ID of the current paste.
private
getPasteId() : string