File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
tests/Coduo/PHPMatcher/Matcher Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Coduo \PHPMatcher \Exception ;
4
+
5
+ class UnknownExpanderClassException extends Exception
6
+ {
7
+ }
Original file line number Diff line number Diff line change 6
6
use Coduo \PHPMatcher \Exception \Exception ;
7
7
use Coduo \PHPMatcher \Exception \InvalidExpanderTypeException ;
8
8
use Coduo \PHPMatcher \Exception \PatternException ;
9
+ use Coduo \PHPMatcher \Exception \UnknownExpanderClassException ;
9
10
use Coduo \PHPMatcher \Exception \UnknownExpanderException ;
10
11
use Coduo \PHPMatcher \Matcher \Pattern ;
11
12
@@ -77,6 +78,20 @@ public function getAST($pattern)
77
78
return $ this ->getPattern ();
78
79
}
79
80
81
+ /**
82
+ * @param $expanderName
83
+ * @param $expanderFQCN Fully-Qualified Class Name that implements PatternExpander interface
84
+ * @throws UnknownExpanderClassException
85
+ */
86
+ public function addExpanderDefinition ($ expanderName , $ expanderFQCN )
87
+ {
88
+ if (!class_exists ($ expanderFQCN )) {
89
+ throw new UnknownExpanderClassException (sprintf ("Class \"%s \" does not exists. " , $ expanderFQCN ));
90
+ }
91
+
92
+ $ this ->expanderDefinitions [$ expanderName ] = $ expanderFQCN ;
93
+ }
94
+
80
95
/**
81
96
* Create AST root
82
97
*
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ class StringMatcherTest extends \PHPUnit_Framework_TestCase
15
15
16
16
public function setUp ()
17
17
{
18
- $ this ->matcher = new StringMatcher (new Parser (new Lexer ()));
18
+ $ parser = new Parser (new Lexer ());
19
+ $ this ->matcher = new StringMatcher ($ parser );
19
20
}
20
21
/**
21
22
* @dataProvider positiveCanMatchData
You can’t perform that action at this time.
0 commit comments