Skip to content

Commit 56989b7

Browse files
committed
Apply fixes from StyleCI
1 parent 3f93f2c commit 56989b7

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

app/Http/Formatters/AlertLogDetailFormatter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function formatPort(array $detail): ?string
112112
($port->ifAlias && $port->ifAlias != $port->ifDescr)
113113
? $this->line('Alias', $port->ifAlias)
114114
: null,
115-
!empty($detail['isisISAdjState'])
115+
! empty($detail['isisISAdjState'])
116116
? $this->line('Adjacent', $detail['isisISAdjIPAddrAddress'] ?? 'Unknown')
117117
: null,
118118
]);
@@ -243,7 +243,7 @@ private function formatApplication(array $detail): ?string
243243
return $this->lines([
244244
$this->linkLine('Application', $app_url, $app_type),
245245
$this->line('Status', $detail['app_status'] ?? null),
246-
!empty($detail['metric'])
246+
! empty($detail['metric'])
247247
? $this->line('Metric', e($detail['metric']) . ' = ' . e($detail['value'] ?? 'N/A'), escape: false)
248248
: null,
249249
]);
@@ -263,6 +263,7 @@ private function line(string $label, mixed $value, bool $escape = true): ?string
263263
}
264264

265265
$formatted_value = $escape ? e($value) : $value;
266+
266267
return $label . ': ' . $formatted_value;
267268
}
268269

@@ -279,7 +280,8 @@ private function linkLine(string $label, string $url, string $text): string
279280
*/
280281
private function inlineList(array $items): ?string
281282
{
282-
$filtered = array_filter($items, fn($item) => $item !== null && $item !== '');
283+
$filtered = array_filter($items, fn ($item) => $item !== null && $item !== '');
284+
283285
return empty($filtered) ? null : implode(', ', $filtered);
284286
}
285287

@@ -288,6 +290,6 @@ private function inlineList(array $items): ?string
288290
*/
289291
private function lines(array $lines): string
290292
{
291-
return implode('<br>', array_filter($lines, fn($line) => $line !== null && $line !== ''));
293+
return implode('<br>', array_filter($lines, fn ($line) => $line !== null && $line !== ''));
292294
}
293295
}

tests/Unit/Http/Formatters/AlertLogDetailFormatterTest.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public function testFormatBasicRuleAlert(): void
1919
{
2020
$details = [
2121
'rule' => [
22-
['message' => 'Test alert', 'value' => 10]
23-
]
22+
['message' => 'Test alert', 'value' => 10],
23+
],
2424
];
2525

2626
$output = $this->formatter->format($details);
@@ -35,15 +35,15 @@ public function testFormatAlertWithDiff(): void
3535
$details = [
3636
'diff' => [
3737
'added' => [
38-
['message' => 'New item']
38+
['message' => 'New item'],
3939
],
4040
'resolved' => [
41-
['message' => 'Fixed item']
42-
]
41+
['message' => 'Fixed item'],
42+
],
4343
],
4444
'rule' => [
45-
['message' => 'Still alert']
46-
]
45+
['message' => 'Still alert'],
46+
],
4747
];
4848

4949
$output = $this->formatter->format($details);
@@ -61,9 +61,9 @@ public function testFormatBill(): void
6161
'rule' => [
6262
[
6363
'bill_id' => 123,
64-
'bill_name' => 'Test Bill'
65-
]
66-
]
64+
'bill_name' => 'Test Bill',
65+
],
66+
],
6767
];
6868

6969
$output = $this->formatter->format($details);
@@ -82,8 +82,8 @@ public function testFormatPort(): void
8282
'device_id' => 1,
8383
'ifDescr' => 'eth0',
8484
'ifAlias' => 'WAN Interface',
85-
]
86-
]
85+
],
86+
],
8787
];
8888

8989
$output = $this->formatter->format($details);
@@ -104,9 +104,9 @@ public function testFormatSensor(): void
104104
'sensor_current' => 35,
105105
'sensor_limit' => 40,
106106
'sensor_limit_warn' => 38,
107-
'sensor_descr' => 'CPU Temp'
108-
]
109-
]
107+
'sensor_descr' => 'CPU Temp',
108+
],
109+
],
110110
];
111111

112112
$output = $this->formatter->format($details);
@@ -128,9 +128,9 @@ public function testFormatSensorState(): void
128128
'sensor_current' => 2,
129129
'state_descr' => 'Critical',
130130
'state_value' => 2, // Used by StateTranslation if constructor receives it
131-
'sensor_descr' => 'Power State'
132-
]
133-
]
131+
'sensor_descr' => 'Power State',
132+
],
133+
],
134134
];
135135

136136
$output = $this->formatter->format($details);
@@ -147,9 +147,9 @@ public function testFormatAccessPoint(): void
147147
[
148148
'accesspoint_id' => 101,
149149
'device_id' => 1,
150-
'name' => 'AP-01'
151-
]
152-
]
150+
'name' => 'AP-01',
151+
],
152+
],
153153
];
154154

155155
$output = $this->formatter->format($details);
@@ -170,9 +170,9 @@ public function testFormatService(): void
170170
'service_type' => 'http',
171171
'service_ip' => '1.2.3.4',
172172
'service_desc' => 'Web Service',
173-
'service_message' => 'Connection refused'
174-
]
175-
]
173+
'service_message' => 'Connection refused',
174+
],
175+
],
176176
];
177177

178178
$output = $this->formatter->format($details);
@@ -195,9 +195,9 @@ public function testFormatBgpPeer(): void
195195
'bgpPeerIdentifier' => '10.0.0.1',
196196
'bgpPeerDescr' => 'ISP-A',
197197
'bgpPeerRemoteAs' => 65001,
198-
'bgpPeerState' => 'idle'
199-
]
200-
]
198+
'bgpPeerState' => 'idle',
199+
],
200+
],
201201
];
202202

203203
$output = $this->formatter->format($details);
@@ -219,9 +219,9 @@ public function testFormatMempool(): void
219219
'mempool_descr' => 'System RAM',
220220
'mempool_perc' => 85.5,
221221
'mempool_free' => 1024 * 1024 * 100, // 100MB
222-
'mempool_total' => 1024 * 1024 * 1024 // 1GB
223-
]
224-
]
222+
'mempool_total' => 1024 * 1024 * 1024, // 1GB
223+
],
224+
],
225225
];
226226

227227
$output = $this->formatter->format($details);
@@ -244,9 +244,9 @@ public function testFormatApplication(): void
244244
'app_type' => 'nginx',
245245
'app_status' => 'up',
246246
'metric' => 'requests',
247-
'value' => 5000
248-
]
249-
]
247+
'value' => 5000,
248+
],
249+
],
250250
];
251251

252252
$output = $this->formatter->format($details);
@@ -267,9 +267,9 @@ public function testFallbackFormatting(): void
267267
'device_id' => 1, // should be skipped
268268
'some_id' => 123, // should be skipped (contains id)
269269
'description' => 'test', // should be skipped (contains desc)
270-
'another_val' => 'present'
271-
]
272-
]
270+
'another_val' => 'present',
271+
],
272+
],
273273
];
274274

275275
$output = $this->formatter->format($details);

0 commit comments

Comments
 (0)