Skip to content

Commit 149b3f4

Browse files
iamfarhadgithub-actions[bot]
authored andcommitted
PHP Linting (Pint)
1 parent 0dd8187 commit 149b3f4

File tree

8 files changed

+25
-24
lines changed

8 files changed

+25
-24
lines changed

src/Collectors/CacheOperationCollector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function registerEventListeners(): void
8383
public function handleCacheHit(CacheHit $event): void
8484
{
8585
// Only track application cache operations, not internal storage operations
86-
if (!$this->shouldTrackCacheOperation($event)) {
86+
if (! $this->shouldTrackCacheOperation($event)) {
8787
return;
8888
}
8989

@@ -95,14 +95,14 @@ public function handleCacheHit(CacheHit $event): void
9595
public function handleCacheMiss(CacheMissed $event): void
9696
{
9797
// Only track application cache operations, not internal storage operations
98-
if (!$this->shouldTrackCacheOperation($event)) {
98+
if (! $this->shouldTrackCacheOperation($event)) {
9999
return;
100100
}
101101

102102
$this->debugCollectorActivity('CacheOperationCollector', 'cache miss tracked', [
103103
'key' => $event->key ?? '',
104104
'store' => $event->storeName ?? 'default',
105-
'tags' => $event->tags ?? []
105+
'tags' => $event->tags ?? [],
106106
]);
107107

108108
$startTime = microtime(true);
@@ -113,7 +113,7 @@ public function handleCacheMiss(CacheMissed $event): void
113113
public function handleKeyWritten(KeyWritten $event): void
114114
{
115115
// Only track application cache operations, not internal storage operations
116-
if (!$this->shouldTrackCacheOperation($event)) {
116+
if (! $this->shouldTrackCacheOperation($event)) {
117117
return;
118118
}
119119

@@ -125,7 +125,7 @@ public function handleKeyWritten(KeyWritten $event): void
125125
public function handleKeyForgotten(KeyForgotten $event): void
126126
{
127127
// Only track application cache operations, not internal storage operations
128-
if (!$this->shouldTrackCacheOperation($event)) {
128+
if (! $this->shouldTrackCacheOperation($event)) {
129129
return;
130130
}
131131

src/Collectors/HttpRequestCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function recordRequest(Request $request, mixed $response, float $startTim
9595
$this->debugCollectorActivity('HttpRequestCollector', 'recording request', [
9696
'method' => $method,
9797
'route' => $route,
98-
'status' => $status
98+
'status' => $status,
9999
]);
100100

101101
// Record request count

src/Collectors/QueueJobCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected function getJobId(mixed $job): string
175175
}
176176

177177
// Fallback to a hash of the job object
178-
return md5(spl_object_hash($job) . microtime());
178+
return md5(spl_object_hash($job).microtime());
179179
}
180180

181181
public function isEnabled(): bool

src/Http/Middleware/PrometheusMetricsMiddleware.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function handle(Request $request, Closure $next): mixed
2424

2525
if (! $this->collector || ! $this->isEnabled()) {
2626
$this->debugInfo('Collector disabled or null - skipping metrics');
27+
2728
return $next($request);
2829
}
2930

src/Prometheus.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Iamfarhad\Prometheus;
66

7-
use InvalidArgumentException;
87
use Iamfarhad\Prometheus\Traits\HasDebugLogging;
8+
use InvalidArgumentException;
99
use Prometheus\CollectorRegistry;
1010
use Prometheus\Counter;
1111
use Prometheus\Gauge;
@@ -28,7 +28,7 @@ public function __construct(
2828
) {
2929
$this->debugInfo('Prometheus instance created', [
3030
'namespace' => $namespace,
31-
'registry_class' => get_class($registry)
31+
'registry_class' => get_class($registry),
3232
]);
3333
}
3434

@@ -181,7 +181,7 @@ public function getOrRegisterSummary(
181181

182182
$this->debugMetricOperation('getOrRegisterSummary', $fullName, $labelNames, [
183183
'max_age_seconds' => $maxAgeSeconds,
184-
'quantiles' => $quantiles
184+
'quantiles' => $quantiles,
185185
]);
186186

187187
return $this->registry->getOrRegisterSummary($this->namespace, $fullName, $help, $labelNames, $maxAgeSeconds, $quantiles);
@@ -201,7 +201,7 @@ public function hasMetric(string $name): bool
201201
$samples = $this->registry->getMetricFamilySamples();
202202

203203
foreach ($samples as $sample) {
204-
if ($sample->getName() === $fullName || $sample->getName() === $this->namespace . '_' . $fullName) {
204+
if ($sample->getName() === $fullName || $sample->getName() === $this->namespace.'_'.$fullName) {
205205
return true;
206206
}
207207
}
@@ -217,7 +217,7 @@ public function collect(): array
217217
$samples = $this->registry->getMetricFamilySamples();
218218

219219
$this->debugTiming('metrics collection', $startTime, [
220-
'samples_count' => count($samples)
220+
'samples_count' => count($samples),
221221
]);
222222

223223
return $samples;
@@ -232,7 +232,7 @@ public function render(): string
232232
$result = $renderer->render($this->collect());
233233

234234
$this->debugTiming('metrics rendering', $startTime, [
235-
'output_size' => strlen($result)
235+
'output_size' => strlen($result),
236236
]);
237237

238238
return $result;

src/PrometheusServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class PrometheusServiceProvider extends ServiceProvider
2525
public function boot(): void
2626
{
2727
$this->publishes([
28-
__DIR__ . '/../config/prometheus.php' => config_path('prometheus.php'),
28+
__DIR__.'/../config/prometheus.php' => config_path('prometheus.php'),
2929
], 'prometheus-config');
3030

31-
$this->mergeConfigFrom(__DIR__ . '/../config/prometheus.php', 'prometheus');
31+
$this->mergeConfigFrom(__DIR__.'/../config/prometheus.php', 'prometheus');
3232

3333
// Register routes if enabled
3434
if ($this->app['config']->get('prometheus.metrics_route.enabled', false)) {
35-
$this->loadRoutesFrom(__DIR__ . '/routes.php');
35+
$this->loadRoutesFrom(__DIR__.'/routes.php');
3636
}
3737

3838
// Register HTTP middleware if auto-registration is enabled
@@ -231,7 +231,7 @@ protected function registerHttpMiddleware(): void
231231
// Silently fail if automatic registration doesn't work
232232
// Users can still register manually
233233
if (config('prometheus.debug', false)) {
234-
\Log::warning('[Prometheus] Automatic middleware registration failed: ' . $e->getMessage());
234+
\Log::warning('[Prometheus] Automatic middleware registration failed: '.$e->getMessage());
235235
}
236236
}
237237
});

src/Support/PrometheusMiddlewareHelper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class PrometheusMiddlewareHelper
1111
{
1212
/**
1313
* Add Prometheus metrics middleware to the application.
14-
*
14+
*
1515
* This is a convenience method for easily adding the middleware
1616
* to Laravel 11+ applications in bootstrap/app.php.
17-
*
17+
*
1818
* Note: Configuration checks are done at runtime in the middleware itself.
1919
*/
2020
public static function register(Middleware $middleware): void
@@ -26,8 +26,8 @@ public static function register(Middleware $middleware): void
2626

2727
/**
2828
* Add Prometheus metrics middleware to specific middleware groups.
29-
*
30-
* @param array $groups The middleware groups to add to (e.g., ['web', 'api'])
29+
*
30+
* @param array $groups The middleware groups to add to (e.g., ['web', 'api'])
3131
*/
3232
public static function registerToGroups(Middleware $middleware, array $groups = ['web', 'api']): void
3333
{

src/Traits/HasDebugLogging.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trait HasDebugLogging
1414
protected function debugLog(string $message, array $context = []): void
1515
{
1616
if ($this->isDebugEnabled()) {
17-
Log::debug('[Prometheus] ' . $message, $context);
17+
Log::debug('[Prometheus] '.$message, $context);
1818
}
1919
}
2020

@@ -24,7 +24,7 @@ protected function debugLog(string $message, array $context = []): void
2424
protected function debugInfo(string $message, array $context = []): void
2525
{
2626
if ($this->isDebugEnabled()) {
27-
Log::info('[Prometheus] ' . $message, $context);
27+
Log::info('[Prometheus] '.$message, $context);
2828
}
2929
}
3030

@@ -34,7 +34,7 @@ protected function debugInfo(string $message, array $context = []): void
3434
protected function debugWarning(string $message, array $context = []): void
3535
{
3636
if ($this->isDebugEnabled()) {
37-
Log::warning('[Prometheus] ' . $message, $context);
37+
Log::warning('[Prometheus] '.$message, $context);
3838
}
3939
}
4040

0 commit comments

Comments
 (0)