Skip to content

Commit 0d6441b

Browse files
authored
Maintenance on CodeBase (#225)
1 parent 90325ce commit 0d6441b

9 files changed

+20
-20
lines changed

Formatter/SimpleFormatter.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public function formatMessage(RecordInterface $record): string
2828
$output = str_replace('%channel%', $record->getChannel(), $output);
2929
$output = str_replace('%level_name%', $record->getLevel()->getName(), $output);
3030
$output = str_replace('%message%', $message, $output);
31-
$output = str_replace('%context%', json_encode($record->getContext()->all()), $output);
3231

33-
return $output;
32+
return str_replace('%context%', json_encode($record->getContext()->all()), $output);
3433
}
3534
}

Handler/FileHandler.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class FileHandler extends AbstractHandler
1616
{
1717
private bool $isOpen = false;
18+
1819
private $handle;
1920

2021
public function __construct(
@@ -44,6 +45,7 @@ private function open(): void
4445
if (false === $this->handle = fopen($this->filename, 'a')) {
4546
throw new RuntimeException(sprintf('"%s" could not be opened', $this->filename));
4647
}
48+
4749
$this->isOpen = true;
4850
}
4951

Handler/StreamHandler.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*/
1313
class StreamHandler extends AbstractHandler
1414
{
15-
private bool $isOpen = false;
16-
1715
public function __construct(private $stream) {}
1816

1917
public function doHandle(RecordInterface $record, string $message): void
@@ -24,7 +22,7 @@ public function doHandle(RecordInterface $record, string $message): void
2422
private function write(string $message): void
2523
{
2624
if (false === fwrite($this->stream, $message)) {
27-
throw new RuntimeException(sprintf('stream could not be written to'));
25+
throw new RuntimeException('stream could not be written to');
2826
}
2927
}
3028
}

Level.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public static function fromName(string $name): LevelInterface
3636
'info' => self::Info,
3737
'debug' => self::Debug,
3838
};
39-
} catch (UnhandledMatchError $e) {
40-
throw new ValueError(sprintf('"%s" is invalid', $name), $e->getCode(), $e);
39+
} catch (UnhandledMatchError $unhandledMatchError) {
40+
throw new ValueError(sprintf('"%s" is invalid', $name), $unhandledMatchError->getCode(), $unhandledMatchError);
4141
}
4242
}
4343

@@ -53,7 +53,7 @@ public static function tryFromName(string $name): ?LevelInterface
5353

5454
public function getName(): string
5555
{
56-
return match($this) {
56+
return match ($this) {
5757
self::Emergency => 'EMERGENCY',
5858
self::Alert => 'ALERT',
5959
self::Critical => 'CRITICAL',
@@ -87,7 +87,7 @@ public function isLowerThan(LevelInterface $level): bool
8787

8888
public function toPsrLogLevel(): string
8989
{
90-
return match($this) {
90+
return match ($this) {
9191
self::Emergency => LogLevel::EMERGENCY,
9292
self::Alert => LogLevel::ALERT,
9393
self::Critical => LogLevel::CRITICAL,

Tests/ContextTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public function testOffsetExists(): void
5252
{
5353
$context = new Context();
5454

55-
$this->assertFalse(isset($context['test']));
55+
$this->assertArrayNotHasKey('test', $context);
5656
$this->assertEmpty($context['test']);
5757

5858
$context['test'] = 'testing';
59-
$this->assertTrue(isset($context['test']));
59+
$this->assertArrayHasKey('test', $context);
6060
$this->assertNotEmpty($context['test']);
6161
}
6262

@@ -65,11 +65,11 @@ public function testOffsetUnset(): void
6565
$context = new Context();
6666

6767
$context['key'] = 'value';
68-
$this->assertTrue(isset($context['key']));
68+
$this->assertArrayHasKey('key', $context);
6969
$this->assertNotEmpty($context['key']);
7070

7171
unset($context['key']);
72-
$this->assertFalse(isset($context['key']));
72+
$this->assertArrayNotHasKey('key', $context);
7373
$this->assertEmpty($context['key']);
7474
}
7575

@@ -78,11 +78,11 @@ public function testOffsetSet(): void
7878
$context = new Context();
7979

8080
$context['test'] = 'unit test';
81-
$this->assertTrue(isset($context['test']));
81+
$this->assertArrayHasKey('test', $context);
8282
$this->assertNotEmpty($context['test']);
8383

8484
$context['key'] = 'value';
85-
$this->assertTrue(isset($context['key']));
85+
$this->assertArrayHasKey('key', $context);
8686
$this->assertNotEmpty($context['key']);
8787
}
8888

@@ -91,7 +91,7 @@ public function testItWillThrowExceptionDuringOffsetExistsWithInvalidOffset(): v
9191
$context = new Context();
9292

9393
$this->expectException('InvalidArgumentException');
94-
isset($context[new stdClass()]);
94+
$context[new stdClass()];
9595
}
9696

9797
public function testItWillThrowExceptionDuringOffsetGetWithInvalidOffset(): void

Tests/Filter/LogLevelFilterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testItHasTheCorrectInterface(): void
2929
public function testConstructWillThrowInvalidArgumentException(): void
3030
{
3131
$this->expectException('InvalidArgumentException');
32-
$filter = new LogLevelFilter('app');
32+
new LogLevelFilter('app');
3333
}
3434

3535
public function testIsLoggableIsTrueWhenLevelIsEqual(): void

Tests/Handler/FileHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#[UsesClass(Level::class)]
2525
final class FileHandlerTest extends TestCase
2626
{
27-
public function setUp(): void
27+
protected function setUp(): void
2828
{
2929
if (file_exists('/tmp/testing.log')) {
3030
unlink('/tmp/testing.log');

Tests/Handler/StreamHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#[UsesClass(Level::class)]
2525
final class StreamHandlerTest extends TestCase
2626
{
27-
public function setUp(): void
27+
protected function setUp(): void
2828
{
2929
if (file_exists('/tmp/testing.log')) {
3030
unlink('/tmp/testing.log');

Tests/LoggerTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
final class LoggerTest extends TestCase
2929
{
3030
private MockObject $enricher;
31+
3132
private MockObject $handler;
3233

33-
public function setUp(): void
34+
protected function setUp(): void
3435
{
3536
$this->enricher = $this->createMock(EnricherInterface::class);
3637
$this->handler = $this->createMock(HandlerInterface::class);

0 commit comments

Comments
 (0)