/** * Parse the template to a URI * * @param string $template * @param array $parameters * @return string */ public function parse($template, $parameters = []) { $this->lexer->setInput($template); $url = ''; while ($this->lexer->moveNext()) { switch ($this->lexer->lookahead['type']) { case Lexer::T_PLACEHOLDER_START: $url .= $this->parsePlaceholder($parameters); break; case Lexer::T_STRING: $url .= $this->lexer->lookahead['value']; break; } } return $url; }
/** * Test lexing an input without placeholders tokenizes as expected * * @covers ::getType */ public function testLexingInputWithoutPlaceholders() { $this->lexer->setInput('/one'); $this->lexer->moveNext(); $this->lexer->moveNext(); $this->assertToken(Lexer::T_STRING, $this->lexer->token['type']); $this->assertEquals('/one', $this->lexer->token['value']); $this->assertNull($this->lexer->lookahead); }