1 | <?php namespace Arcanedev\LaravelMetrics; |
||
15 | class Manager implements ManagerContract |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** @var \Illuminate\Contracts\Foundation\Application */ |
||
23 | protected $app; |
||
24 | |||
25 | /** |
||
26 | * The registered metrics. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $registered = []; |
||
31 | |||
32 | /** |
||
33 | * Selected metrics. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $selected = []; |
||
38 | |||
39 | /* ----------------------------------------------------------------- |
||
40 | | Constructor |
||
41 | | ----------------------------------------------------------------- |
||
42 | */ |
||
43 | |||
44 | /** |
||
45 | * MetricsManager constructor. |
||
46 | * |
||
47 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
48 | */ |
||
49 | 24 | public function __construct(Application $app) |
|
53 | |||
54 | /* ----------------------------------------------------------------- |
||
55 | | Getters & Setters |
||
56 | | ----------------------------------------------------------------- |
||
57 | */ |
||
58 | |||
59 | /** |
||
60 | * Get the registered metrics. |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | 16 | public function registered(): array |
|
68 | |||
69 | /** |
||
70 | * Get the selected metrics. |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 16 | public function selected(): array |
|
78 | |||
79 | /** |
||
80 | * Set the selected metrics. |
||
81 | * |
||
82 | * @param array $metrics |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | 8 | public function setSelected(array $metrics) |
|
92 | |||
93 | /* ----------------------------------------------------------------- |
||
94 | | Main Methods |
||
95 | | ----------------------------------------------------------------- |
||
96 | */ |
||
97 | |||
98 | /** |
||
99 | * Get a metric instance. |
||
100 | * |
||
101 | * @param string $metric |
||
102 | * @param mixed|null $default |
||
103 | * |
||
104 | * @return \Arcanedev\LaravelMetrics\Metrics\Metric|mixed |
||
105 | */ |
||
106 | 4 | public function get(string $metric, $default = null) |
|
110 | |||
111 | /** |
||
112 | * Get/Make the given metric from the container. |
||
113 | * |
||
114 | * @param string $metric |
||
115 | * |
||
116 | * @return \Arcanedev\LaravelMetrics\Metrics\Metric|mixed |
||
117 | */ |
||
118 | 12 | public function make(string $metric): Metric |
|
125 | |||
126 | /** |
||
127 | * Register the metrics. |
||
128 | * |
||
129 | * @param array|string $metrics |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | 8 | public function register($metrics) |
|
144 | |||
145 | /** |
||
146 | * Check if the metric exists. |
||
147 | * |
||
148 | * @param string $metric |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | 8 | public function has(string $metric): bool |
|
157 | |||
158 | /** |
||
159 | * Check if the metric is registered. |
||
160 | * |
||
161 | * @param string $metric |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | 16 | public function isRegistered(string $metric): bool |
|
169 | |||
170 | /** |
||
171 | * Check if the selected metrics is not empty |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | 8 | public function hasSelected(): bool |
|
179 | |||
180 | /** |
||
181 | * Make the selected metrics. |
||
182 | * |
||
183 | * @return \Illuminate\Support\Collection |
||
184 | */ |
||
185 | 4 | public function makeSelected(): Collection |
|
193 | } |
||
194 |