Documentation

QueryUtil
in package

FinalYes

Table of Contents

Constants

BOOLEANS_AS_BOOL  = 0
BOOLEANS_AS_INT  = 1
BOOLEANS_AS_INT_STRING  = 3
BOOLEANS_AS_STRING  = 2
NO_ENCODING  = -1

Methods

build()  : string
Builds a query string from an array of key value pairs.
cleanParams()  : array<int|string, scalar|bool|null>
Cleans/normalizes an array of query parameters
merge()  : string
Merges additional query parameters into an existing query string
parse()  : array<string, string|array<string|int, string>>
Parses a query string into an associative array.
recursiveRawurlencode()  : string|array<string|int, string>
Recursive rawurlencode

Constants

BOOLEANS_AS_BOOL

public mixed BOOLEANS_AS_BOOL = 0

BOOLEANS_AS_INT

public mixed BOOLEANS_AS_INT = 1

BOOLEANS_AS_INT_STRING

public mixed BOOLEANS_AS_INT_STRING = 3

BOOLEANS_AS_STRING

public mixed BOOLEANS_AS_STRING = 2

Methods

build()

Builds a query string from an array of key value pairs.

public static build(array<string, scalar|bool|array<int, scalar|bool|null>|null> $params[, int|null $encoding = null ][, string|null $delimiter = null ][, string|null $enclosure = null ]) : string

Valid values for $encoding are PHP_QUERY_RFC3986 (default) and PHP_QUERY_RFC1738, any other integer value will be interpreted as "no encoding".

Boolean values will be cast to int(0,1), null values will be removed, leaving only their keys.

Parameters
$params : array<string, scalar|bool|array<int, scalar|bool|null>|null>
$encoding : int|null = null
$delimiter : string|null = null
$enclosure : string|null = null
Tags
link
https://github.com/abraham/twitteroauth/blob/57108b31f208d0066ab90a23257cdd7bb974c67d/src/Util.php#L84-L122
link
https://github.com/guzzle/psr7/blob/c0dcda9f54d145bd4d062a6d15f54931a67732f9/src/Query.php#L59-L113
Return values
string

cleanParams()

Cleans/normalizes an array of query parameters

public static cleanParams(array<int|string, scalar|bool|null> $params[, int|null $bool_cast = null ][, bool|null $remove_empty = null ]) : array<int|string, scalar|bool|null>

By default, booleans will be left as-is (BOOLEANS_AS_BOOL) and may result in empty values. If $remove_empty is set to true (default), empty and null values will be removed from the array.

$bool_cast converts booleans to a type determined like following:

  • BOOLEANS_AS_BOOL : unchanged boolean value (default)
  • BOOLEANS_AS_INT : integer values 0 or 1
  • BOOLEANS_AS_STRING : "true"/"false" strings
  • BOOLEANS_AS_INT_STRING: "0"/"1"
Parameters
$params : array<int|string, scalar|bool|null>
$bool_cast : int|null = null
$remove_empty : bool|null = null
Return values
array<int|string, scalar|bool|null>

merge()

Merges additional query parameters into an existing query string

public static merge(string $uri, array<string, scalar|bool|null> $query) : string
Parameters
$uri : string
$query : array<string, scalar|bool|null>
Return values
string

recursiveRawurlencode()

Recursive rawurlencode

public static recursiveRawurlencode(string|array<int, scalar|null> $data) : string|array<string|int, string>
Parameters
$data : string|array<int, scalar|null>
Tags
throws
InvalidArgumentException
Return values
string|array<string|int, string>

        
On this page

Search results