Completed
Push — master ( ddbdaa...f0688c )
by Jeroen De
13:09
created

GraphOptions::isGraphColor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
4
namespace SRF\Graph;
5
6
/**
7
 * Represents a set of Options for the Graph Printer
8
 *
9
 *
10
 * @license GNU GPL v2+
11
 * @since 3.2
12
 *
13
 * @author Sebastian Schmid (gesinn.it)
14
 *
15
 */
16
17
class GraphOptions {
18
19
	/**
20
	 * @var string
21
	 */
22
	private $graphName;
23
24
	/**
25
	 * @var string
26
	 */
27
	private $graphSize;
28
29
	/**
30
	 * @var string
31
	 */
32
	private $nodeShape;
33
34
	/**
35
	 * @var string
36
	 */
37
	private $nodeLabel;
38
39
	/**
40
	 * @var string
41
	 */
42
	private $rankDir;
43
44
	/**
45
	 * @var int
46
	 */
47
	private $wordWrapLimit;
48
49
	/**
50
	 * @var string
51
	 */
52
	private $parentRelation;
53
54
	/**
55
	 * @var boolean
56
	 */
57
	private $enableGraphLink;
58
59
	/**
60
	 * @var boolean
61
	 */
62
	private $showGraphLabel;
63
64
	/**
65
	 * @var boolean
66
	 */
67
	private $showGraphColor;
68
69
	/**
70
	 * @var boolean
71
	 */
72
	private $showGraphLegend;
73
74
	public function __construct( $options ) {
75
		
76
		$this->graphName = trim( $options['graphname'] );
77
		$this->graphSize = trim( $options['graphsize'] );
78
		$this->nodeShape = trim( $options['nodeshape'] );
79
		$this->nodeLabel = trim( $options['nodelabel'] );
80
		$this->rankDir = strtoupper( trim( $options['arrowdirection'] ) );
81
		$this->wordWrapLimit = trim( $options['wordwraplimit'] );
0 ignored issues
show
Documentation Bug introduced by
The property $wordWrapLimit was declared of type integer, but trim($options['wordwraplimit']) is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
82
		$this->parentRelation = strtolower( trim( $options['relation'] ) ) == 'parent';
0 ignored issues
show
Documentation Bug introduced by
The property $parentRelation was declared of type string, but strtolower(trim($options...elation'])) == 'parent' is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
83
		$this->enableGraphLink = trim($options['graphlink']);
0 ignored issues
show
Documentation Bug introduced by
The property $enableGraphLink was declared of type boolean, but trim($options['graphlink']) is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
84
		$this->showGraphLabel = trim($options['graphlabel']);
0 ignored issues
show
Documentation Bug introduced by
The property $showGraphLabel was declared of type boolean, but trim($options['graphlabel']) is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
85
		$this->showGraphColor = trim($options['graphcolor']);
0 ignored issues
show
Documentation Bug introduced by
The property $showGraphColor was declared of type boolean, but trim($options['graphcolor']) is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
86
		$this->showGraphLegend = trim( $options['graphlegend'] );
0 ignored issues
show
Documentation Bug introduced by
The property $showGraphLegend was declared of type boolean, but trim($options['graphlegend']) is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
87
	}
88
89
	/**
90
	 * @return string
91
	 */
92
	public function getGraphName(): string {
93
		return $this->graphName;
94
	}
95
96
	/**
97
	 * @return string
98
	 */
99
	public function getGraphSize(): string {
100
		return $this->graphSize;
101
	}
102
103
	/**
104
	 * @return string
105
	 */
106
	public function getNodeShape(): string {
107
		return $this->nodeShape;
108
	}
109
110
	/**
111
	 * @return string
112
	 */
113
	public function getNodeLabel(): string {
114
		return $this->nodeLabel;
115
	}
116
117
	/**
118
	 * @return string
119
	 */
120
	public function getRankDir(): string {
121
		return $this->rankDir;
122
	}
123
124
	/**
125
	 * @return int
126
	 */
127
	public function getWordWrapLimit(): int {
128
		return $this->wordWrapLimit;
129
	}
130
131
	/**
132
	 * @return string
133
	 */
134
	public function getParentRelation(): string {
135
		return $this->parentRelation;
136
	}
137
138
	/**
139
	 * @return bool
140
	 */
141
	public function isGraphLink(): bool {
142
		return $this->enableGraphLink;
143
	}
144
145
	/**
146
	 * @return bool
147
	 */
148
	public function isGraphLabel(): bool {
149
		return $this->showGraphLabel;
150
	}
151
152
	/**
153
	 * @return bool
154
	 */
155
	public function isGraphColor(): bool {
156
		return $this->showGraphColor;
157
	}
158
159
	/**
160
	 * @return bool
161
	 */
162
	public function isGraphLegend(): bool {
163
		return $this->showGraphLegend;
164
	}
165
}