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