Completed
Push — master ( 25559c...472c56 )
by Josh
20:25
created

TemplateParser::parseEqualityExpr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2018 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\Helpers;
9
10
use s9e\TextFormatter\Configurator\Helpers\TemplateParser\Normalizer;
11
use s9e\TextFormatter\Configurator\Helpers\TemplateParser\Optimizer;
12
use s9e\TextFormatter\Configurator\Helpers\TemplateParser\Parser;
13
14
class TemplateParser
15
{
16
	/**
17
	* XSL namespace
18
	*/
19
	const XMLNS_XSL = 'http://www.w3.org/1999/XSL/Transform';
20
21
	/**
22
	* @var string Regexp that matches the names of all void elements
23
	* @link http://www.w3.org/TR/html-markup/syntax.html#void-elements
24
	*/
25
	public static $voidRegexp = '/^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/Di';
26
27
	/**
28
	* Parse a template into an internal representation
29
	*
30
	* @param  string      $template Source template
31
	* @return DOMDocument           Internal representation
32
	*/
33
	public static function parse($template)
34
	{
35
		$parser = new Parser(new Normalizer(new Optimizer));
36
37
		return $parser->parse($template);
38
	}
39
40
	/**
41
	* Parse an XPath expression that is composed entirely of equality tests between a variable part
42
	* and a constant part
43
	*
44
	* @param  string      $expr
45
	* @return array|false
46
	*/
47
	public static function parseEqualityExpr($expr)
48
	{
49
		return XPathHelper::parseEqualityExpr($expr);
50
	}
51
}