Documentation

Utils
in package

Utility helpers.

Table of Contents

Constants

TEMP_REGEX_AVOID_UNMASK  = 'PLEACE_REPLACE_ME_AGAIN'

Methods

array_flatten()  : mixed
Flatten an array.
createRegexpPatternFromWildcardName()  : mixed
Create a pattern for `preg_match_all` usage.
endsWith()  : mixed
Check if a string starts with a given needle.
removeDuplicateAsterisksInRegex()  : string
Remove duplicate `(.*)` identifiers to avoid "catastrophical backtrace". This also greatly improves performance.
startsWith()  : mixed
Check if a string starts with a given needle.

Constants

TEMP_REGEX_AVOID_UNMASK

public mixed TEMP_REGEX_AVOID_UNMASK = 'PLEACE_REPLACE_ME_AGAIN'

Methods

array_flatten()

Flatten an array.

public static array_flatten(array<string|int, mixed> $array[, bool $recursive = false ]) : mixed
Parameters
$array : array<string|int, mixed>
$recursive : bool = false
Tags
codeCoverageIgnore

createRegexpPatternFromWildcardName()

Create a pattern for `preg_match_all` usage.

public static createRegexpPatternFromWildcardName(string $name) : mixed
Parameters
$name : string

endsWith()

Check if a string starts with a given needle.

public static endsWith(string $haystack, string $needle) : mixed
Parameters
$haystack : string

The string to search in

$needle : string

The starting string

Tags
see
https://stackoverflow.com/a/834355/5506547
codeCoverageIgnore

removeDuplicateAsterisksInRegex()

Remove duplicate `(.*)` identifiers to avoid "catastrophical backtrace". This also greatly improves performance.

public static removeDuplicateAsterisksInRegex(string $regex) : string
Input:  `/^((?:.|\\n)*)((?:.|\\n)*)((?:.|\\n)*)\\.hs\\-scripts\\.com((?:.|\\n)*)$/`
Output: `/^((?:.|\\n)*)                        \\.hs\\-scripts\\.com((?:.|\\n)*)$/`
                       ^^^^^^^^^^^^^^^^^^^^^^^^
                       ^ This is removed
Parameters
$regex : string
Return values
string

startsWith()

Check if a string starts with a given needle.

public static startsWith(string $haystack, string $needle) : mixed
Parameters
$haystack : string

The string to search in

$needle : string

The starting string

Tags
see
https://stackoverflow.com/a/834355/5506547
codeCoverageIgnore

        
On this page

Search results