Completed
Push — master ( 7b17ad...a29029 )
by Tom
02:30
created

Attribute   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 9
Bugs 2 Features 0
Metric Value
wmc 4
c 9
b 2
f 0
lcom 1
cbo 2
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A match() 0 12 3
1
<?php
2
/* @description     Transformation Style Sheets - Revolutionising PHP templating    *
3
 * @author          Tom Butler [email protected]                                             *
4
 * @copyright       2015 Tom Butler <[email protected]> | https://r.je/                      *
5
 * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License *
6
 * @version         1.0                                                             */
7
namespace Transphporm\Pseudo;
8
class Attribute implements \Transphporm\Pseudo {
9
	private $functionSet;
10
11
	public function __construct(\Transphporm\FunctionSet $functionSet) {
12
		$this->functionSet = $functionSet;
13
	}
14
15
	public function match($pseudo, \DomElement $element) {
16
		$pos = strpos($pseudo, '[');
17
		if ($pos === false) return true;
18
19
		$name = substr($pseudo, 0, $pos);
20
		if (!$this->functionSet->hasFunction($name)) return true;
21
22
		$this->functionSet->setElement($element);
23
		$valueParser = new \Transphporm\Parser\Value($this->functionSet);
24
		$valueParser->debug = true;
25
		return $valueParser->parse($pseudo)[0];
26
	}
27
}
28