Utils
    
            
            in package
            
        
    
    
    
        
        
    
Table of Contents
- DEFAULT_JSON_FLAGS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR
 - canonicalizePath() : string
 - Makes sure if a relative path is passed in it is turned into an absolute path
 - expandIniShorthandBytes() : int|false
 - Converts a string with a valid 'memory_limit' format, to bytes.
 - getClass() : string
 - getRecordMessageForException() : string
 - handleJsonError() : string
 - Handle a json_encode failure.
 - jsonEncode() : string
 - Return the JSON representation of a value
 - substr() : string
 - detectAndCleanUtf8() : void
 - Detect invalid UTF-8 string characters and convert to valid UTF-8.
 - throwEncodeError() : never
 - Throws an exception according to a given code with a customized message
 
Constants
DEFAULT_JSON_FLAGS
    public
    mixed
    DEFAULT_JSON_FLAGS
    = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_INVALID_UTF8_SUBSTITUTE | JSON_PARTIAL_OUTPUT_ON_ERROR
        
        
    
Methods
canonicalizePath()
Makes sure if a relative path is passed in it is turned into an absolute path
    public
            static    canonicalizePath(string $streamUrl) : string
    
        Parameters
- $streamUrl : string
 - 
                    
stream URL or path without protocol
 
Return values
string —expandIniShorthandBytes()
Converts a string with a valid 'memory_limit' format, to bytes.
    public
            static    expandIniShorthandBytes(string|false $val) : int|false
    
        Parameters
- $val : string|false
 
Return values
int|false —Returns an integer representing bytes. Returns FALSE in case of error.
getClass()
    public
            static    getClass(object $object) : string
        
        Parameters
- $object : object
 
Return values
string —getRecordMessageForException()
    public
            static    getRecordMessageForException(array<string|int, mixed> $record) : string
    
        Parameters
- $record : array<string|int, mixed>
 
Return values
string —handleJsonError()
Handle a json_encode failure.
    public
            static    handleJsonError(int $code, mixed $data[, int $encodeFlags = null ]) : string
        If the failure is due to invalid string encoding, try to clean the input and encode again. If the second encoding attempt fails, the initial error is not encoding related or the input can't be cleaned then raise a descriptive exception.
Parameters
- $code : int
 - 
                    
return code of json_last_error function
 - $data : mixed
 - 
                    
data that was meant to be encoded
 - $encodeFlags : int = null
 - 
                    
flags to pass to json encode, defaults to JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION
 
Tags
Return values
string —JSON encoded data after error correction
jsonEncode()
Return the JSON representation of a value
    public
            static    jsonEncode(mixed $data[, int $encodeFlags = null ][, bool $ignoreErrors = false ]) : string
    
        Parameters
- $data : mixed
 - $encodeFlags : int = null
 - 
                    
flags to pass to json encode, defaults to DEFAULT_JSON_FLAGS
 - $ignoreErrors : bool = false
 - 
                    
whether to ignore encoding errors or to throw on error, when ignored and the encoding fails, "null" is returned which is valid json for null
 
Tags
Return values
string —when errors are ignored and the encoding fails, "null" is returned which is valid json for null
substr()
    public
            static    substr(string $string, int $start[, int|null $length = null ]) : string
        
        Parameters
- $string : string
 - $start : int
 - $length : int|null = null
 
Return values
string —detectAndCleanUtf8()
Detect invalid UTF-8 string characters and convert to valid UTF-8.
    private
            static    detectAndCleanUtf8(mixed &$data) : void
        Valid UTF-8 input will be left unmodified, but strings containing invalid UTF-8 codepoints will be reencoded as UTF-8 with an assumed original encoding of ISO-8859-15. This conversion may result in incorrect output if the actual encoding was not ISO-8859-15, but it will be clean UTF-8 output and will not rely on expensive and fragile detection algorithms.
Function converts the input in place in the passed variable so that it can be used as a callback for array_walk_recursive.
Parameters
- $data : mixed
 - 
                    
Input to check and convert if needed, passed by ref
 
Return values
void —throwEncodeError()
Throws an exception according to a given code with a customized message
    private
            static    throwEncodeError(int $code, mixed $data) : never
    
        Parameters
- $code : int
 - 
                    
return code of json_last_error function
 - $data : mixed
 - 
                    
data that was meant to be encoded