Completed
Push — master ( 248b54...11da79 )
by Pavel
02:59
created

Option   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 167
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 13
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 167
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getValue() 0 4 1
A endOption() 0 4 1
A setTitle() 0 6 1
A getTitle() 0 4 1
A setClass() 0 10 2
A getClass() 0 4 1
A setClassSecondary() 0 4 1
A getClassSecondary() 0 4 1
A setIcon() 0 6 1
A getIcon() 0 4 1
A getText() 0 4 1
1
<?php
2
3
/**
4
 * @copyright   Copyright (c) 2015 ublaboo <[email protected]>
5
 * @author      Pavel Janda <[email protected]>
6
 * @package     Ublaboo
7
 */
8
9
namespace Ublaboo\DataGrid\Status;
10
11
use Nette;
12
use Ublaboo\DataGrid\Column\ColumnStatus;
13
14
class Option extends Nette\Object
15
{
16
17
	/**
18
	 * @var ColumnStatus
19
	 */
20
	protected $columnStatus;
21
22
	/**
23
	 * @var mixed
24
	 */
25
	protected $value;
26
27
	/**
28
	 * @var string
29
	 */
30
	protected $text;
31
32
	/**
33
	 * @var string|callable
34
	 */
35
	protected $title;
36
37
	/**
38
	 * @var string|callable
39
	 */
40
	protected $class = 'btn-success';
41
42
	/**
43
	 * @var string
44
	 */
45
	protected $class_secondary = 'ajax btn btn-xs';
46
47
	/**
48
	 * @var string|callable
49
	 */
50
	protected $icon;
51
52
53
	/**
54
	 * [__construct description]
55
	 * @param ColumnStatus $columnStatus
56
	 * @param mixed       $value
57
	 * @param string       $text
58
	 */
59
	public function __construct(ColumnStatus $columnStatus, $value, $text)
60
	{
61
		$this->columnStatus = $columnStatus;
62
		$this->value = $value;
63
		$this->text = (string) $text;
64
	}
65
66
67
	/**
68
	 * @return mixed
69
	 */
70
	public function getValue()
71
	{
72
		return $this->value;
73
	}
74
75
76
	/**
77
	 * End option fluent interface and return parent
78
	 * @return ColumnStatus
79
	 */
80
	public function endOption()
81
	{
82
		return $this->columnStatus;
83
	}
84
85
86
	/**
87
	 * @param string $title
88
	 * @return static
89
	 */
90
	public function setTitle($title)
91
	{
92
		$this->title = (string) $title;
93
94
		return $this;
95
	}
96
97
98
	/**
99
	 * @return string
100
	 */
101
	public function getTitle()
102
	{
103
		return $this->title;
104
	}
105
106
107
	/**
108
	 * @param string $class
109
	 * @param string $class_secondary
110
	 * @return static
111
	 */
112
	public function setClass($class, $class_secondary = NULL)
113
	{
114
		$this->class = (string) $class;
115
116
		if ($class_secondary) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $class_secondary of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
117
			$this->class_secondary = $class_secondary;
118
		}
119
120
		return $this;
121
	}
122
123
124
	/**
125
	 * @return string
126
	 */
127
	public function getClass()
128
	{
129
		return $this->class;
130
	}
131
132
133
	/**
134
	 * @param string $class_secondary
135
	 */
136
	public function setClassSecondary($class_secondary)
137
	{
138
		$this->class_secondary = (string) $class_secondary;
139
	}
140
141
142
	/**
143
	 * @return string
144
	 */
145
	public function getClassSecondary()
146
	{
147
		return $this->class_secondary;
148
	}
149
150
151
	/**
152
	 * @param string $icon
153
	 * @return static
154
	 */
155
	public function setIcon($icon)
156
	{
157
		$this->icon = (string) $icon;
158
159
		return $this;
160
	}
161
162
163
	/**
164
	 * @return string
165
	 */
166
	public function getIcon()
167
	{
168
		return $this->icon;
169
	}
170
171
172
	/**
173
	 * @return string
174
	 */
175
	public function getText()
176
	{
177
		return $this->text;
178
	}
179
180
}
181