Completed
Push — master ( 5ec81c...d5ea32 )
by Richard
03:52
created

Config::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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
class Config {
9
	private $properties = [];
10
	private $pseudo = [];
11
	private $functionSet;
12
	private $headers;
13
	private $formatter;
14
	private $baseDir;
0 ignored issues
show
Unused Code introduced by
The property $baseDir is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
	private $line = 0;
16
	private $elementData;
17
	private $xPath;
18
	private $valueParser;
19
20
	public function __construct(Functionset $functionSet, Parser\Value $valueParser, Hook\ElementData $elementData, Hook\Formatter $formatter, Parser\CssToXpath $xPath, FilePath $filePath, &$headers) {
21
		$this->formatter = $formatter;
22
		$this->headers = &$headers;
23
		$this->filePath = $filePath;
0 ignored issues
show
Bug introduced by
The property filePath does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
		$this->functionSet = $functionSet;
25
		$this->elementData = $elementData;
26
		$this->xPath = $xPath;
27
		$this->valueParser = $valueParser;
28
	}
29
30
	public function getFormatter() {
31
		return $this->formatter;
32
	}
33
34
	public function &getHeaders() {
35
		return $this->headers;
36
	}
37
38
	public function getFilePath() {
39
		return $this->filePath;
40
	}
41
42
	public function &getLine() {
43
		return $this->line;
44
	}
45
46
	public function registerFormatter($formatter) {
47
		$this->formatter->register($formatter);
48
	}
49
50
	public function getFunctionSet() {
51
		return $this->functionSet;
52
	}
53
54
	public function getElementData() {
55
		return $this->elementData;
56
	}
57
58
	public function getCssToXpath() {
59
		return $this->xPath;
60
	}
61
62
	public function getValueParser() {
63
		return $this->valueParser;
64
	}
65
66
	public function registerProperty($name, Property $property) {
67
		$this->properties[$name] = $property;
68
	}
69
70
	public function registerPseudo(Pseudo $pseudo) {
71
		$this->pseudo[] = $pseudo;
72
	}
73
74
	public function loadProperties(Hook\PropertyHook $hook) {
75
		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
76
	}
77
78
	public function createPseudoMatcher($pseudo) {
79
		$pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser);
80
		foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction(clone $pseudoFunction);
81
		return $pseudoMatcher;
82
	}
83
84
}
85