ContentReplacer
in package
Replace Text Content
Tags
Table of Contents
Methods
- addAfter() : string|null
- Add line after the line with the string
- addBefore() : string|null
- Add line before the line with the string
- replace() : string
- Replace content
- add() : string|null
- Add text
Methods
addAfter()
Add line after the line with the string
public
addAfter(string $content, string $line, string $after) : string|null
Parameters
- $content : string
-
Whole content.
- $line : string
-
Line to add.
- $after : string
-
String to search.
Return values
string|null —Updated content, or null if not updated.
addBefore()
Add line before the line with the string
public
addBefore(string $content, string $line, string $before) : string|null
Parameters
- $content : string
-
Whole content.
- $line : string
-
Line to add.
- $before : string
-
String to search.
Return values
string|null —Updated content, or null if not updated.
replace()
Replace content
public
replace(string $content, array<string|int, mixed> $replaces) : string
Parameters
- $content : string
- $replaces : array<string|int, mixed>
-
[search => replace]
Return values
stringadd()
Add text
private
add(string $content, string $text, string $pattern, string $replace) : string|null
Parameters
- $content : string
- $text : string
-
Text to add.
- $pattern : string
-
Regexp search pattern.
- $replace : string
-
Regexp replacement including text to add.
Return values
string|null —Updated content, or null if not updated.