Orpheus

core.php

Tags
noinspection

PhpComposerExtensionStubsInspection

Table of Contents

Constants

OPT_ENTITY  = 4
OPT_KEY  = \OPT_VALUE_IS_KEY | \OPT_LABEL_IS_KEY
OPT_LABEL2VALUE  = \OPT_VALUE_IS_VALUE | \OPT_LABEL_IS_KEY
OPT_LABEL_IS_KEY  = 2
OPT_LABEL_IS_VALUE  = 0
OPT_VALUE  = \OPT_VALUE_IS_VALUE | \OPT_LABEL_IS_VALUE
OPT_VALUE2LABEL  = \OPT_VALUE_IS_KEY | \OPT_LABEL_IS_VALUE
OPT_VALUE_IS_KEY  = 1
OPT_VALUE_IS_VALUE  = 0

Functions

matchBits()  : bool
Do a binary test to check $value is matching $reference
scanFolder()  : array<string|int, string>
Scans a directory cleanly.
stringify()  : string
Stringify any variable
toHtml()  : string
Convert a variable to an HTML-readable string
toString()  : string
Convert a variable a Text-readable string
formatException()  : string
Format the input Exception to a human-readable string
getDebugTrace()  : array<string|int, mixed>
Get the debug trace filtered by $filterStartWith
log_report()  : void
Log a report in a file.
log_debug()  : void
Log a debug
log_hack()  : void
Log a hack attempt The log file is the constant LOGFILE_HACK or, if undefined, '.hack'.
log_error()  : void
Log a system error The log file is the constant LOGFILE_SYSTEM or, if undefined, '.log_error'.
sql_error()  : void
Log a sql error The log file is the constant LOGFILE_SQL or, if undefined, '.pdo_error'.
html()  : string
Convert Text to HTML
htmlAttribute()  : string
Format a string to be a html attribute value
array_path_get()  : mixed
Get value from an Array Path
array_path_set()  : void
Set value into array using an Array Path with / as separator.
startReportStream()  : void
Starts a new report stream, all new reports will be added to this stream.
endReportStream()  : void
Ends the current stream by setting current stream to the global one, so you can not end global stream.
transferReportStream()  : bool
Transfers the stream reports to another
addReport()  : bool
Add a report
reportSuccess()  : bool
Report a success
reportInfo()  : bool
Reports an information to the user
reportWarning()  : bool
Reports a warning
reportError()  : bool
Reports an error
hasErrorReports()  : bool
Check if there is error reports
getReports()  : array<string|int, mixed>
Get some/all reports
getFlatReports()  : array<string|int, array<string|int, mixed>>
Get some/all reports as flatten array
formatReportListToHtml()  : string
Get some/all reports as HTML
formatReportToHtml()  : string
Get one report as HTML
displayReportsHtml()  : void
Displays all reports from the list of $domain and displays generated HTML source.
htmlOptions()  : string
Generate the HTML source for options of a select tag For associative arrays, we commonly use the value=>label model (OPT_VALUE2LABEL) but sometimes for associative arrays we could prefer the label=>value model (OPT_LABEL2VALUE).
htmlOption()  : string
Generate HTML option tag
htmlDisabledAttr()  : string
Generate disabled HTML attribute
valueField()  : string
Generate HTML value attribute
array_path_html()  : string
Convert a path to an HTML name attribute E.g. user/password => user[password]
getFormData()  : array<string|int, mixed>
Get post form data
isSupportingInputController()  : bool
fillFormData()  : array<string|int, mixed>
Fill the given data from input form
fillInputValue()  : bool
Fill the given value from input form
convertSpecialChars()  : string
Convert special characters to non-special ones Replace all special characters in $string by the non-special version of theses.
b()  : string
Get the string of a boolean
explodeList()  : array<string|int, mixed>
Split a string by string in limited values
hashString()  : string
Hash string with salt
sql2Time()  : string
Get the date as string
d()  : string
Format the date as string Date format is storing a date, not a specific moment, we don't care about timezone
dt()  : string
Format the date time as string Datetime format is storing a specific moment, we care about timezone
df()  : string
Format the date time as string Datetime format is storing a specific moment, we care about timezone
timeZone()  : DateTimeZone|null
dateToTime()  : int
Convert date to time Allow any format of strtotime() to be converted to time, if time passed, it just returns it.
timeFormatToRegex()  : string
Create time format regex from date() format
parseTime()  : array<string|int, mixed>
Parse time from string to time array
sqlDate()  : string
Get the date as string in SQL format Date format is storing a date, not a specific moment, we don't care about timezone
sqlDatetime()  : string
Get the date time as string in SQL format Datetime format is storing a specific moment, we care about timezone
clientIp()  : string
Get the client public IP
userId()  : int|string
Get the id of the current user
generateRandomString()  : string
Generate a random string
dayTime()  : int
Calculate the day timestamp using the given integer Return the timestamp of the current day of $time according to the midnight hour.
leadZero()  : string
Add zero to the input number
formatDuration_Shortest()  : string
Format duration to closest unit
count_intersect_keys()  : int
Count intersect key in given arrays
getMimeType()  : string
Get the mime type of the given file path
checkDir()  : bool
Ensure path availability as folder
array_insert()  : void
Insert $value in $array at $position
array_add()  : void
Add values from an array to another
array_filter_by_keys()  : array<string|int, mixed>
Filter $array entries by $keys
array_index()  : int
Get the index of $key in $array
array_last()  : mixed|false
Get the last value of $array
array_get()  : mixed
Get value of $array at $index or $default if not found
array_apply()  : array<string|int, mixed>
Apply a user supplied function to every member of an array
array_peer()  : array<string|int, mixed>
Concat key and value in an array with a glue
str_ucfirst()  : string
Make a string's first-only character uppercase
str_ucwords()  : string
Uppercase the first-only character of each word in a string
str_first()  : string
Get the first char of a string
str_last()  : string
Get the last char of a string
reverse_values()  : void
Reverse values
between()  : bool
Check value in between min and max
deleteCookie()  : bool
Delete a HTTP cookie
startSession()  : void
Start a secured PHP Session and initialize Orpheus
is_closure()  : bool
Find whether the given variable is a closure
is_exception()  : bool
Test the given variable is an exception
ms()  : string
Get microsecond as UNIX format
parseHumanSize()  : int
Convert human size to byte unit Some programs, as of PHP, does not respect binary & decimals unit multiples 100kB = 1.000 bytes / 100KiB = 1.024 bytes In case of PHP ini file, 56MB is for PHP 56 * 1024 * 1024 bytes Source: https://en.wikipedia.org/wiki/Byte#Unit_symbol
formatHumanSize()  : string
Convert human size to byte unit You can combine $step and decimal unit as you want Source: https://en.wikipedia.org/wiki/Byte#Unit_symbol

Constants

OPT_ENTITY

public mixed OPT_ENTITY = 4

OPT_KEY

public mixed OPT_KEY = \OPT_VALUE_IS_KEY | \OPT_LABEL_IS_KEY

OPT_LABEL2VALUE

public mixed OPT_LABEL2VALUE = \OPT_VALUE_IS_VALUE | \OPT_LABEL_IS_KEY

OPT_LABEL_IS_KEY

public mixed OPT_LABEL_IS_KEY = 2

OPT_LABEL_IS_VALUE

public mixed OPT_LABEL_IS_VALUE = 0

OPT_VALUE

public mixed OPT_VALUE = \OPT_VALUE_IS_VALUE | \OPT_LABEL_IS_VALUE

OPT_VALUE2LABEL

public mixed OPT_VALUE2LABEL = \OPT_VALUE_IS_KEY | \OPT_LABEL_IS_VALUE

OPT_VALUE_IS_KEY

public mixed OPT_VALUE_IS_KEY = 1

OPT_VALUE_IS_VALUE

public mixed OPT_VALUE_IS_VALUE = 0

Functions

matchBits()

Do a binary test to check $value is matching $reference

matchBits(int $value, int $reference) : bool
Parameters
$value : int

The value to compare.

$reference : int

The reference for the comparison.

Return values
bool

True if $value is binary included in $reference. Do a binary test, compare $value with $reference. This function is very useful to do binary comparison for rights and inclusion in a value.

scanFolder()

Scans a directory cleanly.

scanFolder(string $dir[, bool $reverseOrder = false ]) : array<string|int, string>
Parameters
$dir : string

The path to the directory to scan.

$reverseOrder : bool = false

True to reverse results order. Default value is False.

Tags
noinspection

PhpAutovivificationOnFalseValuesInspection

Return values
array<string|int, string>

An array of the files in this directory.

stringify()

Stringify any variable

stringify(mixed $s) : string
Parameters
$s : mixed

the input data to stringify

Return values
string

toHtml()

Convert a variable to an HTML-readable string

toHtml(mixed $value) : string
Parameters
$value : mixed

the input data to stringify

Tags
see
toString()
Return values
string

toString()

Convert a variable a Text-readable string

toString(mixed $value) : string
Parameters
$value : mixed

the input data to stringify

Tags
see
toHtml()
Return values
string

formatException()

Format the input Exception to a human-readable string

formatException(Throwable $e) : string
Parameters
$e : Throwable
Return values
string

getDebugTrace()

Get the debug trace filtered by $filterStartWith

getDebugTrace([string|null $filterStartWith = null ]) : array<string|int, mixed>
Parameters
$filterStartWith : string|null = null

Exclude functions starting with this value

Return values
array<string|int, mixed>

The filtered backtrace

log_report()

Log a report in a file.

log_report(string|Exception $report, string $file[, string|null $action = null ]) : void

Data are serialized to JSON. Each line of the file is a JSON string of the reports. The log folder is the constant LOGS_PATH.

Parameters
$report : string|Exception

The report to log.

$file : string

The log file path.

$action : string|null = null

The action associated to the report. Default value is an empty string.

Tags
warning

This function require a writable log file.

log_debug()

Log a debug

log_debug(string $report[, string|null $action = null ]) : void

Log a debug. The log file is the constant LOGFILE_DEBUG.

Parameters
$report : string

The debug report to log.

$action : string|null = null

The action associated to the report. Default value is an empty string.

Tags
see
log_report()

log_hack()

Log a hack attempt The log file is the constant LOGFILE_HACK or, if undefined, '.hack'.

log_hack(string $report[, string|null $action = null ]) : void
Parameters
$report : string

The report to log.

$action : string|null = null

The action associated to the report. Default value is an empty string.

Tags
see
log_report()

log_error()

Log a system error The log file is the constant LOGFILE_SYSTEM or, if undefined, '.log_error'.

log_error(string|Throwable $report[, string|null $action = null ]) : void
Parameters
$report : string|Throwable

The report to log.

$action : string|null = null

The action associated to the report. Default value is an empty string.

Tags
see
log_report()

sql_error()

Log a sql error The log file is the constant LOGFILE_SQL or, if undefined, '.pdo_error'.

sql_error(string|Exception $report[, string|null $action = null ]) : void
Parameters
$report : string|Exception

The report to log

$action : string|null = null

The action associated to the report. Default value is an empty string

Tags
see
log_report()

html()

Convert Text to HTML

html(string $text) : string
Parameters
$text : string

The string to convert

Return values
string

htmlAttribute()

Format a string to be a html attribute value

htmlAttribute(mixed $value) : string
Parameters
$value : mixed

The variable to format

Return values
string

The escaped string

array_path_get()

Get value from an Array Path

array_path_get(array<string|int, mixed> $array, string $path[, mixed $default = null ][, bool $pathRequired = false ]) : mixed

Get value from an Array Path using / as separator. Return null if parameters are invalids, $default if the path is not found else the value. If $default is not null and returned value is null, you can infer your parameters are invalids.

Parameters
$array : array<string|int, mixed>

The array to get the value from.

$path : string

The path used to browse the array.

$default : mixed = null

The default value returned if array is valid but key is not found.

$pathRequired : bool = false

True if the path is required. Default value is False.

Return values
mixed

The value from $path in $array.

array_path_set()

Set value into array using an Array Path with / as separator.

array_path_set(array<string|int, mixed>|null &$array, string $path, mixed $value[, bool $overwrite = true ]) : void
Parameters
$array : array<string|int, mixed>|null

$array The array to get the value from.

$path : string

The path used to browse the array.

$value : mixed

The value to set in array

$overwrite : bool = true

True to overwrite existing value. Default value is True.

Tags
see
array_path_get()

startReportStream()

Starts a new report stream, all new reports will be added to this stream.

startReportStream(string $stream) : void
Parameters
$stream : string

The new report stream name

Tags
see
endReportStream()

endReportStream()

Ends the current stream by setting current stream to the global one, so you can not end global stream.

endReportStream() : void
Tags
see
startReportStream()

transferReportStream()

Transfers the stream reports to another

transferReportStream([string|null $from = null ][, string $to = 'global' ]) : bool
Parameters
$from : string|null = null

Transfers $from this stream. Default value is null (current stream).

$to : string = 'global'

Transfers $to this stream. Default value is global.

Return values
bool

addReport()

Add a report

addReport(mixed $report, string $type[, string|null $domain = null ][, string|null $code = null ][, int $severity = 0 ]) : bool

Add the report $message to the list of reports for this $type. The type of the message is commonly 'success' or 'error'.

Parameters
$report : mixed

The report (Commonly a string or an UserException).

$type : string

The type of the message.

$domain : string|null = null

The domain to use to automatically translate the message. Default value is 'global'.

$code : string|null = null

The key code to use for this report. Default is $report.

$severity : int = 0

The severity of report. Default value is 0.

Tags
see

reportSuccess(), reportError()

Return values
bool

False if rejected

reportSuccess()

Report a success

reportSuccess(mixed $report[, string|null $domain = null ]) : bool

Adds the report $message to the list of reports for this type 'success'.

Parameters
$report : mixed

The message to report.

$domain : string|null = null

The domain fo the message. Not used for translation. Default value is global.

Tags
see
addReport()
Return values
bool

False if rejected

reportInfo()

Reports an information to the user

reportInfo(mixed $report[, string|null $domain = null ]) : bool

Adds the report $message to the list of reports for this type 'info'.

Parameters
$report : mixed

The message to report.

$domain : string|null = null

The domain fo the message. Not used for translation. Default value is global.

Tags
see
addReport()
Return values
bool

False if rejected

reportWarning()

Reports a warning

reportWarning(mixed $report[, string|null $domain = null ]) : bool

Adds the report $message to the list of reports for this type 'warning'. Warning come in some special cases, we meet it when we do automatic checks before loading contents and there is something to report to the user.

Parameters
$report : mixed

The message to report.

$domain : string|null = null

The domain fo the message. Not used for translation. Default value is the domain of Exception in case of UserException else 'global'.

Tags
see
addReport()
Return values
bool

False if rejected

reportError()

Reports an error

reportError(mixed $report[, string|null $domain = null ][, int $severity = 1 ]) : bool
Parameters
$report : mixed

The report.

$domain : string|null = null

The domain fo the message. Default value is the domain of Exception in case of UserException else 'global'.

$severity : int = 1

The severity of the error, commonly 1 for standard user error and 0 for warning. Default value is 1.

Tags
see
addReport()

Adds the report $message to the list of reports for this type 'error'.

Return values
bool

False if rejected

hasErrorReports()

Check if there is error reports

hasErrorReports() : bool
Return values
bool

True if there is any error report.

getReports()

Get some/all reports

getReports([string $stream = 'global' ][, string|null $type = null ][, bool $delete = true ]) : array<string|int, mixed>

Get all reports from the list of $domain optionally filtered by type.

Parameters
$stream : string = 'global'

The stream to get the reports. Default value is "global".

$type : string|null = null

Filter results by report type. Default value is null.

$delete : bool = true

True to delete entries from the list. Default value is true.

Tags
see
formatReportListToHtml()
Return values
array<string|int, mixed>

getFlatReports()

Get some/all reports as flatten array

getFlatReports([string $stream = 'global' ][, string|null $type = null ][, bool $delete = true ]) : array<string|int, array<string|int, mixed>>

Get all reports from the list of $domain optionally filtered by type.

Parameters
$stream : string = 'global'

The stream to get the reports. Default value is "global".

$type : string|null = null

Filter results by report type. Default value is null.

$delete : bool = true

True to delete entries from the list. Default value is true.

Tags
see
getReports()
Return values
array<string|int, array<string|int, mixed>>

formatReportListToHtml()

Get some/all reports as HTML

formatReportListToHtml([string $stream = 'global' ][, array<string|int, mixed> $rejected = [] ][, bool $delete = true ]) : string

Get all reports from the list of $domain and generates the HTML source to display.

Parameters
$stream : string = 'global'

The stream to get the reports. Default value is 'global'.

$rejected : array<string|int, mixed> = []

An array of rejected messages. Default value is an empty array.

$delete : bool = true

True to delete entries from the list. Default value is true.

Tags
see
displayReportsHtml()
see
formatReportToHtml()
Return values
string

The renderer HTML.

formatReportToHtml()

Get one report as HTML

formatReportToHtml(string $stream, string $report, string $domain, string $type) : string
Parameters
$stream : string

The stream of the report.

$report : string

The message to report.

$domain : string

The domain of the report.

$type : string

The type of the report.

Return values
string

displayReportsHtml()

Displays all reports from the list of $domain and displays generated HTML source.

displayReportsHtml([string $stream = 'global' ][, array<string|int, string> $rejected = [] ][, bool $delete = true ]) : void
Parameters
$stream : string = 'global'

The stream to display. Default value is 'global'.

$rejected : array<string|int, string> = []

An array of rejected messages. Can be the first parameter.

$delete : bool = true

True to delete entries from the list.

Tags
see
formatReportListToHtml()

htmlOptions()

Generate the HTML source for options of a select tag For associative arrays, we commonly use the value=>label model (OPT_VALUE2LABEL) but sometimes for associative arrays we could prefer the label=>value model (OPT_LABEL2VALUE).

htmlOptions(string|null $fieldPath, array<string|int, mixed> $values[, null $default = null ][, int|null $matches = null ][, string $prefix = '' ][, string $domain = 'global' ]) : string

You can use your own combination with defined constants OPT_VALUE_IS_VALUE, OPT_VALUE_IS_KEY, OPT_LABEL_IS_VALUE and OPT_LABEL_IS_KEY. Common combinations are OPT_LABEL2VALUE, OPT_VALUE2LABEL and OPT_VALUE. The label is prefixed with $prefix and translated using t(). This function allows bi-dimensional arrays in $values, used as option group.

Parameters
$fieldPath : string|null

The name path to the field.

$values : array<string|int, mixed>

The values to build the dropdown menu.

$default : null = null

The default selected value. Default value is null (no selection).

$matches : int|null = null

Define the associativity between array and option values. Default value is OPT_VALUE2LABEL (as null).

$prefix : string = ''

The prefix to use for the text name of values. Default value is an empty string.

$domain : string = 'global'

The domain to apply the Key. Default value is 'global'.

Tags
see
htmlOption()
Return values
string

An HTML source for the built SELECT tag.

htmlOption()

Generate HTML option tag

htmlOption(string $elValue[, string|null $label = null ][, bool $selected = false ][, string $addAttr = '' ]) : string
Parameters
$elValue : string
$label : string|null = null
$selected : bool = false
$addAttr : string = ''
Return values
string

htmlDisabledAttr()

Generate disabled HTML attribute

htmlDisabledAttr() : string
Return values
string

valueField()

Generate HTML value attribute

valueField(string $value) : string
Parameters
$value : string

The value

Return values
string

array_path_html()

Convert a path to an HTML name attribute E.g. user/password => user[password]

array_path_html(string $path) : string
Parameters
$path : string
Return values
string

getFormData()

Get post form data

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

isSupportingInputController()

isSupportingInputController() : bool
Return values
bool

fillFormData()

Fill the given data from input form

fillFormData(array<string|int, mixed>|null &$data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>|null

The data to fill, as pointer.

Tags
see
getFormData()

Fill the given pointer data array with input form data if null. This function is designed to only offset the case where $data is null.

Return values
array<string|int, mixed>

The resulting $data.

fillInputValue()

Fill the given value from input form

fillInputValue(mixed &$value, string $fieldPath[, string|null $default = null ][, bool $pathRequired = false ]) : bool
Parameters
$value : mixed

The value to fill, as pointer.

$fieldPath : string

The array_path to the input form value.

$default : string|null = null

The default value if not found. Default value is null (array_path_get()'s default).

$pathRequired : bool = false

True if the path is required. Default value is False (array_path_get()'s default).

Tags
see
getFormData()
see
array_path_get()

Fill the given pointer value with input form data or uses default.

Return values
bool

True if got value is not null (found).

convertSpecialChars()

Convert special characters to non-special ones Replace all special characters in $string by the non-special version of theses.

convertSpecialChars(string $string) : string
Parameters
$string : string

The string to convert

Return values
string

The string wih no special characters

b()

Get the string of a boolean

b(bool $b) : string
Parameters
$b : bool

The boolean

Return values
string

The boolean's string

explodeList()

Split a string by string in limited values

explodeList(string $delimiter, string $string, int $limit[, mixed $default = null ]) : array<string|int, mixed>
Parameters
$delimiter : string

The boundary string

$string : string

The input string

$limit : int

The limit of values exploded

$default : mixed = null

The default value to use if missing

Tags
see
explode()

Split a string by string in a limited number of values. The main difference with explode() is this function complete missing values with $default. If you want $limit optional, use explode()

Return values
array<string|int, mixed>

The exploded array with a defined limit of values.

hashString()

Hash string with salt

hashString(string $value) : string
Parameters
$value : string
Return values
string

Hash input string with salt (constant USER_SALT) using SHA512

sql2Time()

Get the date as string

sql2Time(string $datetime) : string
Parameters
$datetime : string

The datetime

Return values
string

The date using 'dateFormat' translation key

Date format is storing a date, not a specific moment, we don't care about timezone

d()

Format the date as string Date format is storing a date, not a specific moment, we don't care about timezone

d([int|DateTime $time = TIME ][, bool $utc = false ]) : string
Parameters
$time : int|DateTime = TIME

The UNIX timestamp

$utc : bool = false

Is the time UTC

Return values
string

The date using 'dateFormat' translation key

dt()

Format the date time as string Datetime format is storing a specific moment, we care about timezone

dt([int|DateTime $time = TIME ][, bool $utc = false ]) : string
Parameters
$time : int|DateTime = TIME

The UNIX timestamp

$utc : bool = false

Is the time UTC

Return values
string

The date using 'datetimeFormat' translation key

df()

Format the date time as string Datetime format is storing a specific moment, we care about timezone

df(string $format[, int|DateTime|null $time = TIME ][, string|false|null $timeZone = null ]) : string
Parameters
$format : string

The format to use

$time : int|DateTime|null = TIME

The UNIX timestamp

$timeZone : string|false|null = null

Timezone to use. False for UTC, Null for default or a string to specify the one to use

Return values
string

The date formatted using $format

timeZone()

timeZone(string|DateTimeZone|null $timeZone) : DateTimeZone|null
Parameters
$timeZone : string|DateTimeZone|null
Tags
throws
Exception
Return values
DateTimeZone|null

dateToTime()

Convert date to time Allow any format of strtotime() to be converted to time, if time passed, it just returns it.

dateToTime(int|string|DateTime $date) : int
Parameters
$date : int|string|DateTime

The date or UNIX timestamp

Return values
int

The UNIX timestamp

timeFormatToRegex()

Create time format regex from date() format

timeFormatToRegex(string $format) : string
Parameters
$format : string
Return values
string

parseTime()

Parse time from string to time array

parseTime(string $time[, string $format = SYSTEM_TIME_FORMAT ]) : array<string|int, mixed>
Parameters
$time : string

Parsed time

$format : string = SYSTEM_TIME_FORMAT

Format to use

Tags
throws
Exception
Return values
array<string|int, mixed>

sqlDate()

Get the date as string in SQL format Date format is storing a date, not a specific moment, we don't care about timezone

sqlDate([int|DateTime|string|null $time = TIME ]) : string
Parameters
$time : int|DateTime|string|null = TIME

The UNIX timestamp.

Return values
string

The date using sql format

sqlDatetime()

Get the date time as string in SQL format Datetime format is storing a specific moment, we care about timezone

sqlDatetime([int|DateTime|string|null $time = TIME ][, string $format = 'Y-m-d H:i:s' ]) : string
Parameters
$time : int|DateTime|string|null = TIME

The UNIX timestamp.

$format : string = 'Y-m-d H:i:s'
Return values
string

The date using sql format

clientIp()

Get the client public IP

clientIp() : string
Return values
string

The ip of the client

userId()

Get the id of the current user

userId() : int|string
Return values
int|string

The user's id

generateRandomString()

Generate a random string

generateRandomString([int $length = 64 ][, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ]) : string
Parameters
$length : int = 64

The length of the output string

$keyspace : string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

A string of all possible characters to select from

Return values
string

dayTime()

Calculate the day timestamp using the given integer Return the timestamp of the current day of $time according to the midnight hour.

dayTime([int|null $time = null ][, bool $gmt = true ]) : int
Parameters
$time : int|null = null

The time to get the day time. Default value is current timestamp.

$gmt : bool = true

Is the time GMT

Return values
int

leadZero()

Add zero to the input number

leadZero(int $number[, int $length = 2 ]) : string
Parameters
$number : int

The number

$length : int = 2

The length to add zero

Return values
string

formatDuration_Shortest()

Format duration to closest unit

formatDuration_Shortest(int $duration) : string
Parameters
$duration : int

Duration in seconds

Return values
string

count_intersect_keys()

Count intersect key in given arrays

count_intersect_keys(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : int
Parameters
$array1 : array<string|int, mixed>
$array2 : array<string|int, mixed>
Return values
int

getMimeType()

Get the mime type of the given file path

getMimeType(string $filePath) : string
Parameters
$filePath : string
Return values
string

checkDir()

Ensure path availability as folder

checkDir(string $filePath) : bool
Parameters
$filePath : string
Return values
bool

array_insert()

Insert $value in $array at $position

array_insert(array<string|int, mixed> &$array, int $position, mixed $value) : void
Parameters
$array : array<string|int, mixed>
$position : int
$value : mixed
Tags
set

array_splice()

array_add()

Add values from an array to another

array_add(array<string|int, mixed> &$array, array<string|int, mixed> $other) : void
Parameters
$array : array<string|int, mixed>
$other : array<string|int, mixed>

array_filter_by_keys()

Filter $array entries by $keys

array_filter_by_keys(array<string|int, mixed> $array, array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$keys : array<string|int, mixed>
Return values
array<string|int, mixed>

array_index()

Get the index of $key in $array

array_index(array<string|int, mixed> $array, string|int $key) : int
Parameters
$array : array<string|int, mixed>
$key : string|int
Return values
int

array_last()

Get the last value of $array

array_last(array<string|int, mixed> $array) : mixed|false
Parameters
$array : array<string|int, mixed>
Return values
mixed|false

array_get()

Get value of $array at $index or $default if not found

array_get(array<string|int, mixed> $array, int $index[, mixed $default = null ]) : mixed
Parameters
$array : array<string|int, mixed>
$index : int
$default : mixed = null

array_apply()

Apply a user supplied function to every member of an array

array_apply(array<string|int, mixed> $array, callable $callback[, mixed $userdata = null ][, string &$success = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>

The input array.

$callback : callable

Typically, callback takes on two parameters. The array parameter's value being the first, and the key/index second.

$userdata : mixed = null

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

$success : string = null

TRUE on success or FALSE on failure.

Return values
array<string|int, mixed>

The resulting array

array_peer()

Concat key and value in an array with a glue

array_peer(array<string|int, string> $array[, string $peerGlue = ': ' ]) : array<string|int, mixed>
Parameters
$array : array<string|int, string>
$peerGlue : string = ': '
Return values
array<string|int, mixed>

str_ucfirst()

Make a string's first-only character uppercase

str_ucfirst(string $value) : string
Parameters
$value : string
Return values
string

str_ucwords()

Uppercase the first-only character of each word in a string

str_ucwords(string $value) : string
Parameters
$value : string
Return values
string

str_first()

Get the first char of a string

str_first(string $value) : string
Parameters
$value : string
Return values
string

str_last()

Get the last char of a string

str_last(string $value) : string
Parameters
$value : string
Return values
string

reverse_values()

Reverse values

reverse_values(mixed &$val1, mixed &$val2) : void
Parameters
$val1 : mixed
$val2 : mixed

between()

Check value in between min and max

between(int $value, int $min, int $max) : bool
Parameters
$value : int
$min : int
$max : int
Return values
bool

deleteCookie()

Delete a HTTP cookie

deleteCookie(string $name) : bool
Parameters
$name : string

The name of the cookie to delete

Return values
bool

True if cookie was deleted, false if not found

startSession()

Start a secured PHP Session and initialize Orpheus

startSession([int $type = SESSION_WITH_COOKIE ]) : void
Parameters
$type : int = SESSION_WITH_COOKIE

The type flag of the session

is_closure()

Find whether the given variable is a closure

is_closure(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

True if $v is a closure

is_exception()

Test the given variable is an exception

is_exception(mixed $exception) : bool
Parameters
$exception : mixed
Return values
bool

True if $v is an Exception

ms()

Get microsecond as UNIX format

ms([int|null $precision = null ]) : string
Parameters
$precision : int|null = null
Return values
string

parseHumanSize()

Convert human size to byte unit Some programs, as of PHP, does not respect binary & decimals unit multiples 100kB = 1.000 bytes / 100KiB = 1.024 bytes In case of PHP ini file, 56MB is for PHP 56 * 1024 * 1024 bytes Source: https://en.wikipedia.org/wiki/Byte#Unit_symbol

parseHumanSize(string $size[, bool $forceBinaryStep = false ]) : int
Parameters
$size : string

The human size to parse

$forceBinaryStep : bool = false

For to use binary step even if using decimal unit

Tags
throws
Exception
Return values
int

The byte size

formatHumanSize()

Convert human size to byte unit You can combine $step and decimal unit as you want Source: https://en.wikipedia.org/wiki/Byte#Unit_symbol

formatHumanSize(string $value[, int $step = 1000 ][, bool $useDecimalUnit = true ][, int $allowMax = 10000 ][, string $format = '%s%s' ]) : string
Parameters
$value : string

The byte size to format

$step : int = 1000

The step between units

$useDecimalUnit : bool = true

The unit to use (decimal or binary)

$allowMax : int = 10000

Max value allow in one unit. e.g. with 10.000, you keep a unit until 9.999

$format : string = '%s%s'

The format to use with sprintf(), first string is the value and the second one is the unit.

Return values
string

The formatted size


							
On this page

Search results