Digger Basic Class.
More...
|
static | replace ($templateText, $hashReplacements, $leftQualifier="[", $rightQualifier="]") |
|
static | inPatterns ($value, $patternList, $returnPattern=false) |
|
static | pathValue ($array, $basePath=null, $keyPrefix=null, $keyPostfix=null) |
|
static | initClass ($class, $config=null) |
|
Digger Basic Class.
Digger class of common simple basic functions
- Version
- 3.0
- Author
- Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru
- Copyright
- (c) 2015, SAD-Systems
static initClass |
( |
|
$class, |
|
|
|
$config = null |
|
) |
| |
|
static |
To initialize some class by configuration array.
Only the public methods will be initialized.
- Parameters
-
class | $class | Some class |
array | $config | Configuration array |
static inPatterns |
( |
|
$value, |
|
|
|
$patternList, |
|
|
|
$returnPattern = false |
|
) |
| |
|
static |
Checks if a value matches any of patterns
Example:
- Parameters
-
string | $value | Subject for matching. |
array | $patternList | Array of regular expressions (patterns). |
- Returns
- boolean | string TRUE (or pattern) if specified value matches one of patterns from list. FALSE if no matches.
static pathValue |
( |
|
$array, |
|
|
|
$basePath = null , |
|
|
|
$keyPrefix = null , |
|
|
|
$keyPostfix = null |
|
) |
| |
|
static |
To create a two-dimensional array from multidimensional array by replacing a sequence of keys of the original array to the single path contains this sequence.
- Parameters
-
array | $array | Input multidimensional array |
string | $basePath | (Optional) |
string | $keyPrefix | (Optional) Prefix for key (for example: '[' ) |
string | $keyPostfix | (Optional) Postfix for key (for example: ']' ) |
- Returns
- array two-dimensional array
Example:
$inputArray = [
'a' => [
'b' => [
'c' => 'value'
]
]
];
print_r(self::pathValue($inputArray));
print_r(self::pathValue($inputArray, 'base'));
print_r(self::pathValue($inputArray, 'base', '[', ']'));
Array {
'a/b/c' => 'value'
}
Array {
'base/a/b/c' => 'value'
}
Array {
'[base/a/b/c]' => 'value'
}
static replace |
( |
|
$templateText, |
|
|
|
$hashReplacements, |
|
|
|
$leftQualifier = "[" , |
|
|
|
$rightQualifier = "]" |
|
) |
| |
|
static |
To replace keys in the text template by values.
Example:
$text = "some text with some [KEY1] and [KEY2] ...";
$replacements = array("[KEY1]" => "Value1", "[KEY2]" => "Value2");
- Parameters
-
string | $templateText | Template text. |
hash | $hashReplacements | Hash array of replacements. |
string | $leftQualifier | Left qualifier (by default = '['). |
string | $rightQualifier | Right qualifier (by default = ']'). |
- Returns
- string Template text with replacements.
The documentation for this class was generated from the following file: