Skip to content

Commit 9778380

Browse files
authored
Merge pull request #25 from ITO444/patch-1
Construct BBCode with custom parsers
2 parents f5fba4a + 063e707 commit 9778380

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/BBCode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ final class BBCode
1212

1313
const CASE_SENSITIVE = 0;
1414

15-
public function __construct()
15+
public function __construct($htmlParsers = null, $bbCodeParsers = null)
1616
{
17-
$this->htmlParser = new HTMLParser();
18-
$this->bbCodeParser = new BBCodeParser();
17+
$this->htmlParser = new HTMLParser($htmlParsers);
18+
$this->bbCodeParser = new BBCodeParser($bbCodeParsers);
1919
}
2020

2121
public function only($only = null)

src/Parser/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class Parser
1212

1313
protected $parsers = [];
1414

15+
public function __construct($parsers = null)
16+
{
17+
$this->parsers = $parsers === null ? $this->parsers : $parsers;
18+
}
19+
1520
protected function searchAndReplace(string $pattern, string $replace, string $source): string
1621
{
1722
while (preg_match($pattern, $source)) {

0 commit comments

Comments
 (0)