Documentation

Data
in package
Uses HttpFilterableTrait

Client request data class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
5.2.0

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
Data

filter()

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|null

getDataContentLength()

Get data content length

public getDataContentLength([bool $mb = false ]) : int
Parameters
$mb : bool = false
Return values
int

getDefaultMimeType()

Get default mime type

public static getDefaultMimeType() : string
Return values
string

getMimeType()

Get mime type

public static getMimeType(string $ext) : string|null
Parameters
$ext : string
Return values
string|null

getMimeTypeFromFilename()

Get mime type

public static getMimeTypeFromFilename(string $filename) : string
Parameters
$filename : string
Return values
string

getMimeTypes()

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|null

getRawDataLength()

Get raw data length

public getRawDataLength([bool $mb = false ]) : int
Parameters
$mb : bool = false
Return values
int

getRequest()

Get data parent request

public getRequest() : Request|null
Return values
Request|null

hasData()

Has data

public hasData([string|null $key = null ]) : bool
Parameters
$key : string|null = null
Return values
bool

hasDataContent()

Check if the data content has been prepared

public hasDataContent() : bool
Return values
bool

hasMimeType()

Has mime type

public static hasMimeType(string $ext) : bool
Parameters
$ext : string
Return values
bool

hasRawData()

Has raw data

public hasRawData() : bool
Return values
bool

hasRequest()

Has data parent request

public hasRequest() : bool
Return values
bool

isPrepared()

Check if the data content has been prepared (alias to hasDataContent)

public isPrepared() : bool
Return values
bool

prepare()

Prepare data

public prepare([bool $mb = false ]) : Data
Parameters
$mb : bool = false
Return values
Data

prepareJson()

Method to prepare JSON data content

public prepareJson() : Data
Return values
Data

prepareMultipart()

Method to prepare multi-part data content

public prepareMultipart() : Data
Return values
Data

prepareUrlEncoded()

Method to prepare URL-encoded data content

public prepareUrlEncoded() : Data
Return values
Data

prepareXml()

Method to prepare XML data content

public prepareXml() : Data
Return values
Data

removeAllData()

Remove all data

public removeAllData() : Data
Return values
Data

removeData()

Remove data

public removeData(string $key) : Data
Parameters
$key : string
Return values
Data

setData()

Set data

public setData(array<string|int, mixed>|string $data) : Data
Parameters
$data : array<string|int, mixed>|string
Return values
Data

toArray()

Get data array

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results