class ReplacementModel (View source)

The Replacement model.

Properties

private $regexFlags The search regex flags.
private $replaceValue The replace value.
private $searchValue The search value.

Methods

__construct(string $searchValue, string $replaceValue, bool $isRegex, bool $isCaseSensitive)

Initialize a new replacement model.

bool
replaceInFiles(array $fileKeysArray)

Replace matches with a given string in a given list of files.

array
replaceInBlocksRecursively(array $blocks)

Replace matches in block data recursively.

array
replaceInData(array $data, array $keys)

Replace matches in data for a given list of keys.

mixed
replaceInValueRecursively(array|object|string $value)

Replace searched string in a value that is either a string or an multidimensional array of strings.

Details

__construct(string $searchValue, string $replaceValue, bool $isRegex, bool $isCaseSensitive)

Initialize a new replacement model.

Parameters

string $searchValue
string $replaceValue
bool $isRegex
bool $isCaseSensitive

bool replaceInFiles(array $fileKeysArray)

Replace matches with a given string in a given list of files.

Parameters

array $fileKeysArray

Return Value

bool true on success

See also

FileKeysModel

private array replaceInBlocksRecursively(array $blocks)

Replace matches in block data recursively.

Parameters

array $blocks

Return Value

array the processed blocks

private array replaceInData(array $data, array $keys)

Replace matches in data for a given list of keys.

Parameters

array $data
array $keys

Return Value

array the processed data array

private mixed replaceInValueRecursively(array|object|string $value)

Replace searched string in a value that is either a string or an multidimensional array of strings.

Parameters

array|object|string $value

Return Value

mixed $value