Completed
Push — master ( e70e95...72eb9f )
by Josh
04:30
created

DisallowCopy::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2019 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\TemplateChecks;
9
10
use DOMElement;
11
use s9e\TextFormatter\Configurator\Exceptions\UnsafeTemplateException;
12
use s9e\TextFormatter\Configurator\Items\Tag;
13
use s9e\TextFormatter\Configurator\TemplateCheck;
14
15
class DisallowCopy extends TemplateCheck
16
{
17
	/**
18
	* Check for <xsl:copy/> elements
19
	*
20
	* @param  DOMElement $template <xsl:template/> node
21
	* @param  Tag        $tag      Tag this template belongs to
22
	* @return void
23
	*/
24 1
	public function check(DOMElement $template, Tag $tag)
25
	{
26 1
		$nodes = $template->getElementsByTagNameNS(self::XMLNS_XSL, 'copy');
27 1
		$node  = $nodes->item(0);
28
29 1
		if ($node)
30
		{
31 1
			throw new UnsafeTemplateException("Cannot assess the safety of an '" . $node->nodeName . "' element", $node);
32
		}
33
	}
34
}