Data
in package
Uses
HttpFilterableTrait
Client request data class
Tags
Table of Contents
Constants
- POP_CLIENT_REQUEST_RAW_DATA = 'POP_CLIENT_REQUEST_RAW_DATA'
- Raw data constant
Properties
- $data : array<string|int, mixed>
- Data fields (form fields and files) $data = [ 'username' => 'admin' 'file1' => [ 'filename' => __DIR__ . '/path/to/file.txt', 'contentType' => 'text/plain' ], 'file2' => [ 'filename' => 'test.pdf', 'contentType' => 'application/pdf', 'contents' => file_get_contents(__DIR__ . '/path/to/test.pdf' ] ]
- $dataContent : string|null
- Data content
- $defaultMimeType : string
- Default mime type
- $mimeTypes : array<string|int, mixed>
- Common mime types
- $prepared : bool
- Data content prepared flag
- $request : Request|null
- Data parent request
Methods
- __construct() : mixed
- Constructor
- addData() : Data
- Add data
- filter() : mixed
- Filter values
- getData() : mixed
- Get data
- getDataContent() : string|null
- Get prepared data content
- getDataContentLength() : int
- Get data content length
- getDefaultMimeType() : string
- Get default mime type
- getMimeType() : string|null
- Get mime type
- getMimeTypeFromFilename() : string
- Get mime type
- getMimeTypes() : array<string|int, mixed>
- Get common mime types
- getRawData() : string|null
- Get raw data
- getRawDataLength() : int
- Get raw data length
- getRequest() : Request|null
- Get data parent request
- hasData() : bool
- Has data
- hasDataContent() : bool
- Check if the data content has been prepared
- hasMimeType() : bool
- Has mime type
- hasRawData() : bool
- Has raw data
- hasRequest() : bool
- Has data parent request
- isPrepared() : bool
- Check if the data content has been prepared (alias to hasDataContent)
- prepare() : Data
- Prepare data
- prepareJson() : Data
- Method to prepare JSON data content
- prepareMultipart() : Data
- Method to prepare multi-part data content
- prepareUrlEncoded() : Data
- Method to prepare URL-encoded data content
- prepareXml() : Data
- Method to prepare XML data content
- removeAllData() : Data
- Remove all data
- removeData() : Data
- Remove data
- reset() : Data
- Reset data
- setData() : Data
- Set data
- setRequest() : Data
- Set data parent request
- toArray() : array<string|int, mixed>
- Get data array
Constants
POP_CLIENT_REQUEST_RAW_DATA
Raw data constant
public
mixed
POP_CLIENT_REQUEST_RAW_DATA
= 'POP_CLIENT_REQUEST_RAW_DATA'
Properties
$data
Data fields (form fields and files) $data = [ 'username' => 'admin' 'file1' => [ 'filename' => __DIR__ . '/path/to/file.txt', 'contentType' => 'text/plain' ], 'file2' => [ 'filename' => 'test.pdf', 'contentType' => 'application/pdf', 'contents' => file_get_contents(__DIR__ . '/path/to/test.pdf' ] ]
protected
array<string|int, mixed>
$data
= []
$dataContent
Data content
protected
string|null
$dataContent
= null
$defaultMimeType
Default mime type
protected
static string
$defaultMimeType
= 'application/octet-stream'
$mimeTypes
Common mime types
protected
static array<string|int, mixed>
$mimeTypes
= ['bmp' => 'image/x-ms-bmp', 'bz2' => 'application/bzip2', 'csv' => 'text/csv', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'gif' => 'image/gif', 'gz' => 'application/gzip', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'json' => 'application/json', 'log' => 'text/plain', 'pdf' => 'application/pdf', 'png' => 'image/png', 'ppt' => 'application/msword', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'psd' => 'image/x-photoshop', 'svg' => 'image/svg+xml', 'tar' => 'application/x-tar', 'tbz' => 'application/bzip2', 'tbz2' => 'application/bzip2', 'tgz' => 'application/gzip', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tsv' => 'text/tsv', 'txt' => 'text/plain', 'xls' => 'application/msword', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xml' => 'application/xml', 'zip' => 'application/zip']
$prepared
Data content prepared flag
protected
bool
$prepared
= false
$request
Data parent request
protected
Request|null
$request
= null
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed>|string $data = [] ][, mixed $filters = null ][, Request|null $request = null ]) : mixed
Instantiate the request data object
Parameters
- $data : array<string|int, mixed>|string = []
- $filters : mixed = null
- $request : Request|null = null
addData()
Add data
public
addData(array<string|int, mixed>|string $data[, mixed $value = null ]) : Data
Parameters
- $data : array<string|int, mixed>|string
- $value : mixed = null
Return values
Datafilter()
Filter values
public
filter(mixed $values) : mixed
Parameters
- $values : mixed
getData()
Get data
public
getData([string|null $key = null ]) : mixed
Parameters
- $key : string|null = null
getDataContent()
Get prepared data content
public
getDataContent() : string|null
Return values
string|nullgetDataContentLength()
Get data content length
public
getDataContentLength([bool $mb = false ]) : int
Parameters
- $mb : bool = false
Return values
intgetDefaultMimeType()
Get default mime type
public
static getDefaultMimeType() : string
Return values
stringgetMimeType()
Get mime type
public
static getMimeType(string $ext) : string|null
Parameters
- $ext : string
Return values
string|nullgetMimeTypeFromFilename()
Get mime type
public
static getMimeTypeFromFilename(string $filename) : string
Parameters
- $filename : string
Return values
stringgetMimeTypes()
Get common mime types
public
static getMimeTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>getRawData()
Get raw data
public
getRawData() : string|null
Return values
string|nullgetRawDataLength()
Get raw data length
public
getRawDataLength([bool $mb = false ]) : int
Parameters
- $mb : bool = false
Return values
intgetRequest()
Get data parent request
public
getRequest() : Request|null
Return values
Request|nullhasData()
Has data
public
hasData([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolhasDataContent()
Check if the data content has been prepared
public
hasDataContent() : bool
Return values
boolhasMimeType()
Has mime type
public
static hasMimeType(string $ext) : bool
Parameters
- $ext : string
Return values
boolhasRawData()
Has raw data
public
hasRawData() : bool
Return values
boolhasRequest()
Has data parent request
public
hasRequest() : bool
Return values
boolisPrepared()
Check if the data content has been prepared (alias to hasDataContent)
public
isPrepared() : bool
Return values
boolprepare()
Prepare data
public
prepare([bool $mb = false ]) : Data
Parameters
- $mb : bool = false
Return values
DataprepareJson()
Method to prepare JSON data content
public
prepareJson() : Data
Return values
DataprepareMultipart()
Method to prepare multi-part data content
public
prepareMultipart() : Data
Return values
DataprepareUrlEncoded()
Method to prepare URL-encoded data content
public
prepareUrlEncoded() : Data
Return values
DataprepareXml()
Method to prepare XML data content
public
prepareXml() : Data
Return values
DataremoveAllData()
Remove all data
public
removeAllData() : Data
Return values
DataremoveData()
Remove data
public
removeData(string $key) : Data
Parameters
- $key : string
Return values
Datareset()
Reset data
public
reset() : Data
Return values
DatasetData()
Set data
public
setData(array<string|int, mixed>|string $data) : Data
Parameters
- $data : array<string|int, mixed>|string
Return values
DatasetRequest()
Set data parent request
public
setRequest(Request $request) : Data
Parameters
- $request : Request
Return values
DatatoArray()
Get data array
public
toArray() : array<string|int, mixed>