@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WMDE\PsrLogTestDoubles; |
6 | 6 | |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Signature changed in 3.0 |
22 | 22 | */ |
23 | - public function log( $level, string|\Stringable $message, array $context = [] ): void { |
|
24 | - $this->logCalls[] = new LogCall( $level, (string)$message, $context ); |
|
23 | + public function log($level, string|\Stringable $message, array $context = []): void { |
|
24 | + $this->logCalls[] = new LogCall($level, (string)$message, $context); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @since 2.0 |
29 | 29 | */ |
30 | 30 | public function getLogCalls(): LogCalls { |
31 | - return new LogCalls( ...$this->logCalls ); |
|
31 | + return new LogCalls(...$this->logCalls); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @throws AssertionException |
44 | 44 | */ |
45 | 45 | public function assertNoLoggingCallsWhereMade(): void { |
46 | - if ( !empty( $this->logCalls ) ) { |
|
46 | + if (!empty($this->logCalls)) { |
|
47 | 47 | throw new AssertionException( |
48 | - 'Logger calls where made while non where expected: ' . var_export( $this->logCalls, true ) |
|
48 | + 'Logger calls where made while non where expected: ' . var_export($this->logCalls, true) |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WMDE\PsrLogTestDoubles; |
6 | 6 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | */ |
22 | 22 | private array $calls; |
23 | 23 | |
24 | - public function __construct( LogCall... $calls ) { |
|
24 | + public function __construct(LogCall... $calls) { |
|
25 | 25 | $this->calls = $calls; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function getIterator(): \ArrayIterator { |
29 | - return new \ArrayIterator( $this->calls ); |
|
29 | + return new \ArrayIterator($this->calls); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getMessages(): array { |
36 | 36 | return array_map( |
37 | - function( LogCall $logCall ) { |
|
37 | + function(LogCall $logCall) { |
|
38 | 38 | return $logCall->getMessage(); |
39 | 39 | }, |
40 | 40 | $this->calls |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @since 3.1 |
50 | 50 | */ |
51 | 51 | public function getLastCall(): ?LogCall { |
52 | - return $this->calls[count( $this->calls ) - 1] ?? null; |
|
52 | + return $this->calls[count($this->calls) - 1] ?? null; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return int |
58 | 58 | */ |
59 | 59 | public function count(): int { |
60 | - return count( $this->calls ); |
|
60 | + return count($this->calls); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param callable(LogCall):bool $filter |
66 | 66 | * @return self |
67 | 67 | */ |
68 | - public function filter( callable $filter ): self { |
|
69 | - return new self( ...array_filter( $this->calls, $filter ) ); |
|
68 | + public function filter(callable $filter): self { |
|
69 | + return new self(...array_filter($this->calls, $filter)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @since 3.2 |
75 | 75 | */ |
76 | 76 | public function getErrors(): self { |
77 | - return $this->filter( fn( LogCall $call ) => $call->isError() ); |
|
77 | + return $this->filter(fn(LogCall $call) => $call->isError()); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | * @param callable(LogCall):LogCall $map |
83 | 83 | * @return self |
84 | 84 | */ |
85 | - public function map( callable $map ): self { |
|
85 | + public function map(callable $map): self { |
|
86 | 86 | $calls = []; |
87 | 87 | |
88 | - foreach ( $this->calls as $call ) { |
|
89 | - $calls[] = $map( $call ); |
|
88 | + foreach ($this->calls as $call) { |
|
89 | + $calls[] = $map($call); |
|
90 | 90 | } |
91 | 91 | |
92 | - return new self( ...$calls ); |
|
92 | + return new self(...$calls); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @since 3.2 |
98 | 98 | */ |
99 | 99 | public function withoutContexts(): self { |
100 | - return $this->map( fn( LogCall $call ) => $call->withoutContext() ); |
|
100 | + return $this->map(fn(LogCall $call) => $call->withoutContext()); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WMDE\PsrLogTestDoubles; |
6 | 6 | |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class LogCall { |
16 | 16 | |
17 | - private const ERROR_LEVELS = [ LogLevel::ERROR, LogLevel::CRITICAL, LogLevel::ALERT, LogLevel::EMERGENCY ]; |
|
17 | + private const ERROR_LEVELS = [LogLevel::ERROR, LogLevel::CRITICAL, LogLevel::ALERT, LogLevel::EMERGENCY]; |
|
18 | 18 | |
19 | 19 | private mixed $level; |
20 | 20 | private string $message; |
21 | 21 | private array $context; |
22 | 22 | |
23 | - public function __construct( mixed $level, string $message, array $context = [] ) { |
|
23 | + public function __construct(mixed $level, string $message, array $context = []) { |
|
24 | 24 | $this->level = $level; |
25 | 25 | $this->message = $message; |
26 | 26 | $this->context = $context; |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @since 3.2 |
44 | 44 | */ |
45 | 45 | public function isError(): bool { |
46 | - return in_array( $this->level, self::ERROR_LEVELS ); |
|
46 | + return in_array($this->level, self::ERROR_LEVELS); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @since 3.2 |
51 | 51 | */ |
52 | 52 | public function withoutContext(): self { |
53 | - return new self( $this->level, $this->message, [] ); |
|
53 | + return new self($this->level, $this->message, []); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | } |