Config   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 82
Duplicated Lines 10.98 %

Coupling/Cohesion

Components 4
Dependencies 3

Importance

Changes 0
Metric Value
wmc 18
lcom 4
cbo 3
dl 9
loc 82
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A getFormatter() 0 3 1
A getHeaders() 0 3 1
A getFilePath() 0 3 1
A getLine() 0 4 1
A registerFormatter() 0 3 1
A getFunctionSet() 0 3 1
A getElementData() 0 3 1
A getCssToXpath() 0 3 1
A getValueParser() 0 3 1
A registerProperty() 0 3 1
A loadProperties() 0 3 2
A createPseudoMatcher() 0 5 2
A registerContentPseudo() 0 3 2
A registerPseudo() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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;
8
class Config {
9
	private $properties = [];
10
	private $pseudo = [];
11
	private $functionSet;
12
	private $headers;
13
	private $filePath;
14
	private $formatter;
15
	private $line = 0;
16
	private $elementData;
17
	private $xPath;
18
	private $valueParser;
19
20 View Code Duplication
	public function __construct(Functionset $functionSet, Parser\Value $valueParser, Hook\ElementData $elementData, Hook\Formatter $formatter, Parser\CssToXpath $xPath, FilePath $filePath, &$headers) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
		$this->formatter = $formatter;
22
		$this->headers = &$headers;
23
		$this->filePath = $filePath;
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
        $line = &$this->line;
44
		return $line;
45
	}
46
47
	public function registerFormatter($formatter) {
48
		$this->formatter->register($formatter);
49
	}
50
51
	public function getFunctionSet() {
52
		return $this->functionSet;
53
	}
54
55
	public function getElementData() {
56
		return $this->elementData;
57
	}
58
59
	public function getCssToXpath() {
60
		return $this->xPath;
61
	}
62
63
	public function getValueParser() {
64
		return $this->valueParser;
65
	}
66
67
	public function registerProperty($name, Property $property) {
68
		$this->properties[$name] = $property;
69
	}
70
71
    public function registerContentPseudo($name, Property\ContentPseudo $pseudo) {
72
        if (isset($this->properties['content'])) $this->properties['content']->addContentPseudo($name, $pseudo);
73
    }
74
75
	public function registerPseudo($name, Pseudo $pseudo) {
76
		$this->pseudo[$name] = $pseudo;
77
	}
78
79
	public function loadProperties(Hook\PropertyHook $hook) {
80
		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
81
	}
82
83
	public function createPseudoMatcher($pseudo) {
84
		$pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser);
85
		foreach ($this->pseudo as $name => $pseudoFunction) $pseudoMatcher->registerFunction($name, clone $pseudoFunction);
86
		return $pseudoMatcher;
87
	}
88
89
}
90