Completed
Push — master ( 926afa...e2c192 )
by Tom
03:08
created

FunctionSet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 6
c 5
b 0
f 1
lcom 1
cbo 0
dl 0
loc 29
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addFunction() 0 3 1
A __construct() 0 3 1
A __call() 0 7 2
A hasFunction() 0 3 1
A setElement() 0 3 1
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;
8
/* Handles data() and iteration() function calls from the stylesheet */
9
class FunctionSet {
10
	private $elementData;
11
	private $functions = [];
12
	private $element;
13
14
	public function __construct(Hook\ElementData $elementData) {
15
		$this->elementData = $elementData;
16
	}
17
18
	public function __call($name, $args) {
19
		if (isset($this->functions[$name])) {			
20
			return $this->functions[$name]->run($args[0], $this->element);
21
		}
22
		return true;
23
		//else return \Transphporm\Parser\Value::IS_NOT_FUNCTION;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
	}
25
26
	public function addFunction($name, \Transphporm\TSSFunction $function) {
27
		$this->functions[$name] = $function;
28
	}
29
	
30
	public function hasFunction($name) {
31
		return isset($this->functions[$name]);
32
	}
33
34
	public function setElement(\DomElement $element) {
35
		$this->element = $element;
36
	}
37
}
38