Functions::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
rs 9.7
cc 1
nc 1
nop 1
1
<?php
2
/* @description     Transformation Style Sheets - Revolutionising PHP templating    *
3
 * @author          Tom Butler [email protected]                                             *
4
 * @copyright       2017 Tom Butler <[email protected]> | https://r.je/                      *
5
 * @license         http://www.opensource.org/licenses/bsd-license.php  BSD License *
6
 * @version         1.2                                                             */
7
namespace Transphporm\Module;
8
use Transphporm\TSSFunction\Math;
9
/** Assigns all the basic functions, data(), key(), iteration(), template(), etc    */
10
class Functions implements \Transphporm\Module {
11
12
	public function load(\Transphporm\Config $config) {
13
		$functionSet = $config->getFunctionSet();
14
		$baseDir = $config->getFilePath();
15
16
		$functionSet->addFunction('attr', new \Transphporm\TSSFunction\Attr());
17
		$functionSet->addFunction('data', new \Transphporm\TSSFunction\Data($config->getElementData(), $functionSet, 'data'));
18
		$functionSet->addFunction('root', new \Transphporm\TSSFunction\Data($config->getElementData(), $functionSet, 'root'));
19
		$functionSet->addFunction('key', new \Transphporm\TSSFunction\Data($config->getElementData(), $functionSet, 'key'));
20
		$functionSet->addFunction('iteration', new \Transphporm\TSSFunction\Data($config->getElementData(), $functionSet, 'iteration'));
21
		$templateFunction = new \Transphporm\TSSFunction\Template($config->getElementData(), $config->getCssToXpath(), $baseDir);
22
		$functionSet->addFunction('template', $templateFunction);
23
		$functionSet->addFunction('json', new \Transphporm\TSSFunction\Json($baseDir));
24
        $functionSet->addFunction('constant', new \Transphporm\TSSFunction\Constant());
25
26
		// Register HTML formatter here because it uses the template function
27
		$config->registerFormatter(new \Transphporm\Formatter\HTMLFormatter($templateFunction));
28
	}
29
}
30