Completed
Push — master ( 84255c...a7d7e4 )
by Thomas
14:38
created

Page::setTitleSuffix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace keeko\core\kernel;
3
4
use phootwork\collection\ArrayList;
5
6
class Page {
7
8
	private $styles;
9
	private $scripts;
10
	
11
	private $title;
12
	private $titleSuffix;
13
	private $titlePrefix;
14
	private $defaultTitle;
15
	
16
	public function __construct() {
17
		$this->styles = new ArrayList();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
18
		$this->scripts = new ArrayList();
19
	}
20
21
	/**
22
	 * @return string
23
	 */
24
	public function getTitle() {
25
		return $this->title;
26
	}
27
28
	/**
29
	 * @param string $title
30
	 */
31
	public function setTitle($title) {
32
		$this->title = $title;
33
		return $this;
34
	}
35
	
36
	/**
37
	 * @return string
38
	 */
39
	public function getDefaultTitle() {
40
		return $this->defaultTitle;
41
	}
42
	
43
	/**
44
	 * @param string $title
45
	 */
46
	public function setDefaultTitle($title) {
47
		$this->defaultTitle = $title;
48
		return $this;
49
	}
50
51
	/**
52
	 * @return string
53
	 */
54
	public function getTitleSuffix() {
55
		return $this->titleSuffix;
56
	}
57
58
	/**
59
	 * @param string $titleSuffix
60
	 */
61
	public function setTitleSuffix($titleSuffix) {
62
		$this->titleSuffix = $titleSuffix;
63
		return $this;
64
	}
65
66
	/**
67
	 * @return string
68
	 */
69
	public function getTitlePrefix() {
70
		return $this->titlePrefix;
71
	}
72
73
	/**
74
	 * @param string $titlePrefix
75
	 */
76
	public function setTitlePrefix($titlePrefix) {
77
		$this->titlePrefix = $titlePrefix;
78
		return $this;
79
	}
80
	
81
	public function getFullTitle() {
82
		if ($this->title === null) {
83
			return $this->defaultTitle;
84
		}
85
		return trim($this->titlePrefix . ' ' . $this->title . ' ' . $this->titleSuffix);
86
	}
87
	
88
	public function addStyle($style) {
89
		if (!$this->styles->contains($style)) {
90
			$this->styles->add($style);
91
		}
92
		return $this;
93
	}
94
	
95
	public function hasStyle($style) {
96
		return $this->styles->contains($style);
97
	}
98
	
99
	public function removeStyle($style) {
100
		$this->styles->remove($style);
101
		return $this;
102
	}
103
	
104
	public function getStyles() {
105
		return $this->styles->toArray();
106
	}
107
	
108
	public function addScript($script) {
109
		if (!$this->scripts->contains($script)) {
110
			$this->scripts->add($script);
111
		}
112
		return $this;
113
	}
114
	
115
	public function hasScript($script) {
116
		return $this->scripts->contains($script);
117
	}
118
	
119
	public function removeScript($script) {
120
		$this->scripts->remove($script);
121
		return $this;
122
	}
123
	
124
	public function getScripts() {
125
		return $this->scripts->toArray();
126
	}
127
}