Skip to content

Commit cd0bffa

Browse files
authored
Merge pull request #12 from Innmind/cs
Use promoted properties
2 parents 536044c + ebe3163 commit cd0bffa

7 files changed

Lines changed: 14 additions & 37 deletions

File tree

src/LineParser/ApacheAccess.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ final class ApacheAccess implements LineParser
3333
{
3434
private const FORMAT = '~^(?P<client>\S+) - (?P<user>\S+) \[(?P<time>\d{2}/[a-zA-Z]{3}/\d{4}:\d{2}:\d{2}:\d{2} [+\-]\d{4})] "(?P<method>[A-Z]{3,}) (?P<path>.+) HTTP/(?P<protocol>\d\.\d)" (?P<code>\d+) (?P<size>\d+)$~';
3535

36-
private Clock $clock;
37-
38-
private function __construct(Clock $clock)
36+
private function __construct(private Clock $clock)
3937
{
40-
$this->clock = $clock;
4138
}
4239

4340
#[\Override]

src/LineParser/Monolog.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ final class Monolog implements LineParser
3232
private const FORMAT = '~^\[(?P<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] (?P<channel>[a-zA-Z-_]+)\.(?P<level>EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG): (?P<message>.+) (?P<context>[\{\[].*[\]\}]) (?P<extra>[\{\[].*[\]\}])$~';
3333
private const FORMAT_WITHOUT_EXTRA = '~^\[(?P<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] (?P<channel>[a-zA-Z-_]+)\.(?P<level>EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG): (?P<message>.+) (?P<context>[\{\[].*[\]\}])$~';
3434

35-
private Clock $clock;
36-
private string $format;
37-
38-
private function __construct(Clock $clock, ?string $format = null)
39-
{
40-
$this->clock = $clock;
41-
$this->format = $format ?? self::FORMAT;
35+
private function __construct(
36+
private Clock $clock,
37+
private string $format,
38+
) {
4239
}
4340

4441
#[\Override]

src/Log.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,14 @@
1616
*/
1717
final class Log
1818
{
19-
private Point $time;
20-
private Str $raw;
21-
/** @var Set<Attribute> */
22-
private Set $attributes;
23-
2419
/**
2520
* @param Set<Attribute> $attributes
2621
*/
27-
private function __construct(Point $time, Str $raw, Set $attributes)
28-
{
29-
$this->time = $time;
30-
$this->raw = $raw;
31-
$this->attributes = $attributes;
22+
private function __construct(
23+
private Point $time,
24+
private Str $raw,
25+
private Set $attributes,
26+
) {
3227
}
3328

3429
/**

src/Log/Attribute/Monolog/Channel.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
*/
1515
final class Channel implements Attribute
1616
{
17-
private string $value;
18-
19-
private function __construct(string $value)
17+
private function __construct(private string $value)
2018
{
21-
$this->value = $value;
2219
}
2320

2421
/**

src/Log/Attribute/Monolog/Level.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
*/
1313
final class Level implements Attribute
1414
{
15-
private string $value;
16-
17-
private function __construct(string $value)
15+
private function __construct(private string $value)
1816
{
19-
$this->value = $value;
2017
}
2118

2219
/**

src/Log/Attribute/Monolog/Message.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
*/
1515
final class Message implements Attribute
1616
{
17-
private string $value;
18-
19-
private function __construct(string $value)
17+
private function __construct(private string $value)
2018
{
21-
$this->value = $value;
2219
}
2320

2421
/**

src/Reader.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
*/
1212
final class Reader
1313
{
14-
private LineParser $parse;
15-
16-
private function __construct(LineParser $parser)
14+
private function __construct(private LineParser $parse)
1715
{
18-
$this->parse = $parser;
1916
}
2017

2118
#[\NoDiscard]

0 commit comments

Comments
 (0)