@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | * @param array<LogLevel::*, string|int>|null $levelMap |
82 | 82 | * Keys are LogLevel::*, values are alternative strings or integers used as log levels in the SUT. |
83 | 83 | */ |
84 | - public function __construct(array|null $levelMap = null) |
|
84 | + public function __construct(array | null $levelMap = null) |
|
85 | 85 | { |
86 | 86 | if (\is_array($levelMap)) { |
87 | 87 | $passedKeys = \array_keys($levelMap); |
88 | 88 | if ($passedKeys !== \array_keys($this->levelMap)) { |
89 | - throw new \InvalidArgumentException('Level map keys must be the LogLevel::* values; passed ' . \print_r($passedKeys, true)); |
|
89 | + throw new \InvalidArgumentException('Level map keys must be the LogLevel::* values; passed '.\print_r($passedKeys, true)); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->records[] = $record; |
111 | 111 | } |
112 | 112 | |
113 | - public function hasRecords(string|int $level): bool |
|
113 | + public function hasRecords(string | int $level): bool |
|
114 | 114 | { |
115 | 115 | return isset($this->recordsByLevel[$level]); |
116 | 116 | } |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @param string|array<string, mixed> $record |
120 | 120 | */ |
121 | - public function hasRecord(string|array $record, string|int $level): bool |
|
121 | + public function hasRecord(string | array $record, string | int $level): bool |
|
122 | 122 | { |
123 | 123 | if (\is_string($record)) { |
124 | 124 | $record = ['message' => $record]; |
125 | 125 | } |
126 | 126 | |
127 | - return $this->hasRecordThatPasses(static function (array $rec) use ($record) { |
|
127 | + return $this->hasRecordThatPasses(static function(array $rec) use ($record) { |
|
128 | 128 | if ($rec['message'] !== $record['message']) { |
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - return ! isset($record['context']) || $rec['context'] === $record['context']; |
|
132 | + return !isset($record['context']) || $rec['context'] === $record['context']; |
|
133 | 133 | }, $level); |
134 | 134 | } |
135 | 135 | |
136 | - public function hasRecordThatContains(string $message, string|int $level): bool |
|
136 | + public function hasRecordThatContains(string $message, string | int $level): bool |
|
137 | 137 | { |
138 | - return $this->hasRecordThatPasses(static function (array $rec) use ($message) { |
|
138 | + return $this->hasRecordThatPasses(static function(array $rec) use ($message) { |
|
139 | 139 | return \strpos($rec['message'], $message) !== false; |
140 | 140 | }, $level); |
141 | 141 | } |
142 | 142 | |
143 | - public function hasRecordThatMatches(string $regex, string|int $level): bool |
|
143 | + public function hasRecordThatMatches(string $regex, string | int $level): bool |
|
144 | 144 | { |
145 | - return $this->hasRecordThatPasses(static function ($rec) use ($regex) { |
|
145 | + return $this->hasRecordThatPasses(static function($rec) use ($regex) { |
|
146 | 146 | return \preg_match($regex, $rec['message']) > 0; |
147 | 147 | }, $level); |
148 | 148 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * @param callable(array<string, mixed>, int): bool $predicate |
152 | 152 | */ |
153 | - public function hasRecordThatPasses(callable $predicate, string|int $level): bool |
|
153 | + public function hasRecordThatPasses(callable $predicate, string | int $level): bool |
|
154 | 154 | { |
155 | - if (! isset($this->recordsByLevel[$level])) { |
|
155 | + if (!isset($this->recordsByLevel[$level])) { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | public function __call(string $method, array $args): bool |
172 | 172 | { |
173 | 173 | $levelNames = \implode('|', \array_map('ucfirst', \array_keys($this->levelMap))); |
174 | - if (\preg_match('/(.*)(' . $levelNames . ')(.*)/', $method, $matches) > 0) { |
|
175 | - $genericMethod = $matches[1] . ($matches[3] !== 'Records' ? 'Record' : '') . $matches[3]; |
|
174 | + if (\preg_match('/(.*)('.$levelNames.')(.*)/', $method, $matches) > 0) { |
|
175 | + $genericMethod = $matches[1].($matches[3] !== 'Records' ? 'Record' : '').$matches[3]; |
|
176 | 176 | $callable = [$this, $genericMethod]; |
177 | 177 | $level = $this->levelMap[\strtolower($matches[2])]; |
178 | 178 | if (\is_callable($callable)) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - throw new \BadMethodCallException('Call to undefined method ' . static::class . '::' . $method . '()'); |
|
185 | + throw new \BadMethodCallException('Call to undefined method '.static::class.'::'.$method.'()'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | public function reset(): void |