diff --git a/match.php b/match.php index a77bb73e..1a867113 100644 --- a/match.php +++ b/match.php @@ -1,15 +1,6 @@ createMatcher(); return $matcher->match($value, $pattern); } diff --git a/src/Coduo/PHPMatcher/Factory.php b/src/Coduo/PHPMatcher/Factory.php new file mode 100644 index 00000000..f45e5f3a --- /dev/null +++ b/src/Coduo/PHPMatcher/Factory.php @@ -0,0 +1,10 @@ +buildMatchers()); + } + + /** + * @return Matcher\ChainMatcher + */ + protected function buildMatchers() + { + $scalarMatchers = $this->buildScalarMatchers(); + $arrayMatcher = new Matcher\ArrayMatcher($scalarMatchers); + + return new Matcher\ChainMatcher(array( + $scalarMatchers, + $arrayMatcher, + new Matcher\JsonMatcher($arrayMatcher) + )); + } + + /** + * @return Matcher\ChainMatcher + */ + protected function buildScalarMatchers() + { + return new Matcher\ChainMatcher(array( + new Matcher\CallbackMatcher(), + new Matcher\ExpressionMatcher(), + new Matcher\TypeMatcher(), + new Matcher\NullMatcher(), + new Matcher\ScalarMatcher(), + new Matcher\WildcardMatcher() + )); + } +} diff --git a/tests/Coduo/PHPMatcher/Factory/SimpleFactoryTest.php b/tests/Coduo/PHPMatcher/Factory/SimpleFactoryTest.php new file mode 100644 index 00000000..241d6ae5 --- /dev/null +++ b/tests/Coduo/PHPMatcher/Factory/SimpleFactoryTest.php @@ -0,0 +1,14 @@ +assertInstanceOf('Coduo\PHPMatcher\Matcher', $factory->createMatcher()); + } +}