Tools
Table of Contents
Functions
- is_assoc_array() : bool
- Checks if a given array is an associative array.
- to_upper_camel_case() : string
- Converts a string to UpperCamelCase.
- cprint() : void
- Conditionally prints a message to the console. The specified $message will only be printed if $condition is true.
- bandwidth_to_bits() : int
- Converts a $bandwidth to bits for it's given $bandwidthtype
- http_request() : bool|string
- Makes an HTTP request.
- get_classes_from_namespace() : array<string|int, mixed>
- Obtains the classes nested under a specified namespace. This only works for namespaces that match the directory structure (e.g. RESTAPI\Core for /usr/local/pkg/RESTAPI/Core) and only includes classes defined in their own class .inc file with a matching name.
Functions
is_assoc_array()
Checks if a given array is an associative array.
is_assoc_array(array<string|int, mixed> $array) : bool
Parameters
- $array : array<string|int, mixed>
-
The array to check.
Return values
bool —true
if the value is an associative array. false
if it is an indexed array.
to_upper_camel_case()
Converts a string to UpperCamelCase.
to_upper_camel_case(string $string) : string
Parameters
- $string : string
-
The string to convert to UpperCamelCase.
Return values
string —The string converted to UpperCamelCase.
cprint()
Conditionally prints a message to the console. The specified $message will only be printed if $condition is true.
cprint(string $message, bool $condition) : void
Parameters
- $message : string
-
The message to be printed if the $condition is true.
- $condition : bool
-
A true or false condition. If the condition is true, the $message will be printed. Otherwise it will not.
bandwidth_to_bits()
Converts a $bandwidth to bits for it's given $bandwidthtype
bandwidth_to_bits(int $bandwidth, string $scale) : int
Parameters
- $bandwidth : int
-
The amount of bandwidth scaled using $bandwidthtype.
- $scale : string
-
The scale of $bandwidth. Options are: b, Kb, Mb, and Gb.
Tags
Return values
int —The bandwidth's total number of bits.
http_request()
Makes an HTTP request.
http_request(string $url, string $method[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ][, string $username = '' ][, string $password = '' ][, bool $validate_certs = true ]) : bool|string
Parameters
- $url : string
-
The full URL of the resource to submit the request to.
- $method : string
-
The HTTP method to use to submit the request.
- $data : array<string|int, mixed> = []
-
The data payload to submit to the remote host. Only JSON payloads are supported.
- $headers : array<string|int, mixed> = []
-
The HTTP headers to submit in the request.
- $username : string = ''
-
The username portion for basic authentication (if applicable)
- $password : string = ''
-
The password portion for basic authentication (if applicable)
- $validate_certs : bool = true
-
Enables or disables TLS certificate verification.
Return values
bool|string —The response from the remote host.
get_classes_from_namespace()
Obtains the classes nested under a specified namespace. This only works for namespaces that match the directory structure (e.g. RESTAPI\Core for /usr/local/pkg/RESTAPI/Core) and only includes classes defined in their own class .inc file with a matching name.
get_classes_from_namespace(string $namespace[, bool $shortnames = false ]) : array<string|int, mixed>
Parameters
- $namespace : string
-
The namespace to obtain classes from. This must be the full namespace including leading and trailing slash (\Full\Namespace).
- $shortnames : bool = false
-
Obtain the class shortnames instead of FQNs.
Return values
array<string|int, mixed> —An array containing the class names for each .inc class file.