1 | <?php namespace Arcanedev\LaravelMetrics\Results; |
||
12 | class PartitionResult extends Result |
||
13 | { |
||
14 | /* ----------------------------------------------------------------- |
||
15 | | Properties |
||
16 | | ----------------------------------------------------------------- |
||
17 | */ |
||
18 | |||
19 | /** |
||
20 | * The custom label names. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | public $labels = []; |
||
25 | |||
26 | /** |
||
27 | * The custom label colors. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | public $colors = []; |
||
32 | |||
33 | /** |
||
34 | * The sort direction [asc, desc]. |
||
35 | * |
||
36 | * @var string|null |
||
37 | */ |
||
38 | private $sort; |
||
39 | |||
40 | /* ----------------------------------------------------------------- |
||
41 | | Setters |
||
42 | | ----------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * Set the value. |
||
47 | * |
||
48 | * @param mixed $value |
||
49 | * |
||
50 | * @return $this|mixed |
||
51 | */ |
||
52 | 28 | public function value($value) |
|
58 | |||
59 | /* ----------------------------------------------------------------- |
||
60 | | Getters & Setters |
||
61 | | ----------------------------------------------------------------- |
||
62 | */ |
||
63 | |||
64 | /** |
||
65 | * Format the labels for the partition result. |
||
66 | * |
||
67 | * @param \Closure $callback |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | 4 | public function label(Closure $callback) |
|
77 | |||
78 | /** |
||
79 | * Set the labels for the partition result. |
||
80 | * |
||
81 | * @param array $labels |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | 4 | public function labels(array $labels) |
|
91 | |||
92 | /** |
||
93 | * Set the colors for the partition result. |
||
94 | * |
||
95 | * @param \Closure $callback |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | 4 | public function color(Closure $callback) |
|
105 | |||
106 | /** |
||
107 | * Set the custom label colors. |
||
108 | * |
||
109 | * @param array $colors |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | 4 | public function colors(array $colors) |
|
119 | |||
120 | /** |
||
121 | * Set the sort direction. |
||
122 | * |
||
123 | * @param string $direction |
||
124 | * |
||
125 | * @return $this |
||
126 | */ |
||
127 | 4 | public function sort(string $direction) |
|
134 | |||
135 | /* ----------------------------------------------------------------- |
||
136 | | Common Methods |
||
137 | | ----------------------------------------------------------------- |
||
138 | */ |
||
139 | |||
140 | /** |
||
141 | * Convert the metric object to array. |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | 28 | public function toArray(): array |
|
161 | |||
162 | /* ----------------------------------------------------------------- |
||
163 | | Other Methods |
||
164 | | ----------------------------------------------------------------- |
||
165 | */ |
||
166 | |||
167 | /** |
||
168 | * Transform the value by the given callback |
||
169 | * |
||
170 | * @param \Closure $callback |
||
171 | * |
||
172 | * @return \Illuminate\Support\Collection |
||
173 | */ |
||
174 | 28 | private function mapValue(Closure $callback) |
|
180 | } |
||
181 |