diff --git a/src/StringTemplate/AbstractEngine.php b/src/StringTemplate/AbstractEngine.php index 1b16431..2b77b35 100644 --- a/src/StringTemplate/AbstractEngine.php +++ b/src/StringTemplate/AbstractEngine.php @@ -21,7 +21,7 @@ * //Prints "This is b and these are d and e" * */ -abstract class AbstractEngine +abstract class AbstractEngine implements EngineInterface { protected $left; protected $right; @@ -43,4 +43,4 @@ public function __construct($left = '{', $right = '}') * @return string The rendered template */ abstract public function render($template, $value); -} \ No newline at end of file +} diff --git a/src/StringTemplate/EngineFactory.php b/src/StringTemplate/EngineFactory.php new file mode 100644 index 0000000..c5b8154 --- /dev/null +++ b/src/StringTemplate/EngineFactory.php @@ -0,0 +1,40 @@ + 'StringTemplate\Engine', + 'sprintf' => 'StringTemplate\SprintfEngine' + ); + } +} diff --git a/src/StringTemplate/EngineInterface.php b/src/StringTemplate/EngineInterface.php new file mode 100644 index 0000000..983a942 --- /dev/null +++ b/src/StringTemplate/EngineInterface.php @@ -0,0 +1,17 @@ +assertInstanceOf('StringTemplate\Engine', EngineFactory::create()); + } + + public function testRegular() + { + $this->assertInstanceOf('StringTemplate\Engine', EngineFactory::create('regular')); + } + + public function testSprintf() + { + $this->assertInstanceOf('StringTemplate\SprintfEngine', EngineFactory::create('sprintf')); + } +}