-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatistic.php
164 lines (127 loc) · 4.94 KB
/
Statistic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
namespace Onimla\SemanticUI;
use Onimla\HTML\Node;
use Onimla\SemanticUI\Component;
use Onimla\SemanticUI\Constant;
use Onimla\HTML\HasAttribute;
use Onimla\HTML\Appendable;
class Statistic extends Node implements HasAttribute {
use Traits\Colored,
Traits\Horizontal;
public function __construct($value = FALSE, $label = FALSE) {
parent::__construct();
/* Instâncias =============================================================== */
$this->container = new Component;
$this->value($value);
$this->label($label);
/* Atributos ================================================================ */
$this->container->getClassAttribute()->append(Constant::STATISTIC);
/* Árvore =================================================================== */
$this->container->value = $this->getValue();
$this->container->label = $this->getLabel();
}
public function __clone() {
$this->container = clone $this->container;
$this->value = $this->container->value;
$this->label = $this->container->label;
}
public function __toString() {
return call_user_func(array($this->container, __FUNCTION__));
}
public function addClass($class) {
call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
return $this;
}
public function attr($name, $value = FALSE, $output = FALSE) {
call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
return strlen($value) < 1 ? call_user_func_array(array($this->container, __FUNCTION__), func_get_args()) : $this;
}
public function data($key, $value = FALSE, $output = 'encode') {
call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
return strlen($value) < 1 ? call_user_func_array(array($this->container, __FUNCTION__), func_get_args()) : $this;
}
public function findByAttr($attr, $value) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function findById($value) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function findByName($value) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function getClassAttribute() {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function id($value = FALSE) {
call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
return strlen($value) < 1 ? call_user_func_array(array($this->container, __FUNCTION__), func_get_args()) : $this;
}
public function matchAttr($attr, $regexOrString, $level = FALSE) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function matchClass($classes, $level = FALSE) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function removeAttr($name) {
return call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
}
public function removeClass($class) {
call_user_func_array(array($this->container, __FUNCTION__), func_get_args());
return $this;
}
public function getContainer() {
return $this->container;
}
public function getValue() {
if (!isset($this->value)) {
$this->value = new Statistic\Value();
}
return $this->value;
}
public function setValue($instance) {
if ($instance instanceof HasAttribute OR $instance instanceof Appendable) {
$this->value = $instance;
} else {
$this->value = new Statistic\Value($instance);
}
}
public function unsetValue() {
$tmp = $this->getValue();
unset($this->value);
$this->getValue();
return $tmp;
}
public function value($instance = FALSE) {
if (func_get_args() > 0) {
$this->setValue($instance);
return $this;
}
return $this->getValue();
}
public function getLabel() {
if (!isset($this->label)) {
$this->label = new Statistic\Label();
}
return $this->label;
}
public function setLabel($instance) {
if ($instance instanceof HasAttribute OR $instance instanceof Appendable) {
$this->label = $instance;
} else {
$this->label = new Statistic\Label($instance);
}
}
public function unsetLabel() {
$tmp = $this->getLabel();
unset($this->label);
$this->getLabel();
return $tmp;
}
public function label($instance = FALSE) {
if (func_get_args() > 0) {
$this->setLabel($instance);
return $this;
}
return $this->getLabel();
}
}