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

FeatureSet   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 11
c 1
b 0
f 1
lcom 3
cbo 2
dl 0
loc 44
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getData() 0 3 1
A getFormatter() 0 3 1
A getHeaders() 0 3 1
A registerFormatter() 0 3 1
A registerProperty() 0 3 1
A registerPseudo() 0 3 1
A loadProperties() 0 3 2
A createPseudoMatcher() 0 5 2
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
}