Completed
Push — master ( 73e1e5...4f3b07 )
by Tom
02:36
created

FeatureSet::getFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Transphporm;
3
class FeatureSet {
4
	private $properties = [];
5
	private $pseudo = [];
6
7
	public function __construct(Hook\DataFunction $data, Hook\Formatter $formatter, &$headers) {
8
		$this->data = $data;
0 ignored issues
show
Bug introduced by
The property data 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...
9
		$this->formatter = $formatter;
0 ignored issues
show
Bug introduced by
The property formatter 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...
10
		$this->headers = &$headers;
0 ignored issues
show
Bug introduced by
The property headers 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...
11
	}
12
13
	public function getData() {
14
		return $this->data;
15
	}
16
17
	public function getFormatter() {
18
		return $this->formatter;
19
	}
20
21
	public function &getHeaders() {
22
		return $this->headers;
23
	}
24
25
	public function registerFormatter($formatter) {
26
		$this->formatter->register($formatter);
27
	}
28
29
	public function registerProperty($name, Property $property) {
30
		$this->properties[$name] = $property;
31
	}
32
33
	public function registerPseudo(Pseudo $pseudo) {
34
		$this->pseudo[] = $pseudo;
35
	}
36
37
	public function loadProperties(Hook\PropertyHook $hook) {
38
		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
39
	}
40
41
	public function createPseudoMatcher($pseudo) {
42
		$pseudoMatcher = new Hook\PseudoMatcher($pseudo);
43
		foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction($pseudoFunction);
44
		return $pseudoMatcher;
45
	}
46
}