@@ -81,13 +81,13 @@ 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 | // Assert that $levelMap contains exactly the same keys (no more or less) than LogLevel::* values |
88 | 88 | $diff = \array_diff(\array_keys($levelMap), \array_values($this->levelMap)); |
89 | 89 | if (\count($diff) > 0) { |
90 | - throw new \InvalidArgumentException('Level map keys must be the LogLevel::* values; passed ' . \print_r($levelMap, true)); |
|
90 | + throw new \InvalidArgumentException('Level map keys must be the LogLevel::* values; passed '.\print_r($levelMap, true)); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $this->records[] = $record; |
112 | 112 | } |
113 | 113 | |
114 | - public function hasRecords(string|int $level): bool |
|
114 | + public function hasRecords(string | int $level): bool |
|
115 | 115 | { |
116 | 116 | return isset($this->recordsByLevel[$level]); |
117 | 117 | } |
@@ -119,31 +119,31 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string|array<string, mixed> $record |
121 | 121 | */ |
122 | - public function hasRecord(string|array $record, string|int $level): bool |
|
122 | + public function hasRecord(string | array $record, string | int $level): bool |
|
123 | 123 | { |
124 | 124 | if (\is_string($record)) { |
125 | 125 | $record = ['message' => $record]; |
126 | 126 | } |
127 | 127 | |
128 | - return $this->hasRecordThatPasses(static function (array $rec) use ($record) { |
|
128 | + return $this->hasRecordThatPasses(static function(array $rec) use ($record) { |
|
129 | 129 | if ($rec['message'] !== $record['message']) { |
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - return ! isset($record['context']) || $rec['context'] === $record['context']; |
|
133 | + return !isset($record['context']) || $rec['context'] === $record['context']; |
|
134 | 134 | }, $level); |
135 | 135 | } |
136 | 136 | |
137 | - public function hasRecordThatContains(string $message, string|int $level): bool |
|
137 | + public function hasRecordThatContains(string $message, string | int $level): bool |
|
138 | 138 | { |
139 | - return $this->hasRecordThatPasses(static function (array $rec) use ($message) { |
|
139 | + return $this->hasRecordThatPasses(static function(array $rec) use ($message) { |
|
140 | 140 | return \strpos($rec['message'], $message) !== false; |
141 | 141 | }, $level); |
142 | 142 | } |
143 | 143 | |
144 | - public function hasRecordThatMatches(string $regex, string|int $level): bool |
|
144 | + public function hasRecordThatMatches(string $regex, string | int $level): bool |
|
145 | 145 | { |
146 | - return $this->hasRecordThatPasses(static function ($rec) use ($regex) { |
|
146 | + return $this->hasRecordThatPasses(static function($rec) use ($regex) { |
|
147 | 147 | return \preg_match($regex, $rec['message']) > 0; |
148 | 148 | }, $level); |
149 | 149 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * @param callable(array<string, mixed>, int): bool $predicate |
153 | 153 | */ |
154 | - public function hasRecordThatPasses(callable $predicate, string|int $level): bool |
|
154 | + public function hasRecordThatPasses(callable $predicate, string | int $level): bool |
|
155 | 155 | { |
156 | - if (! isset($this->recordsByLevel[$level])) { |
|
156 | + if (!isset($this->recordsByLevel[$level])) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | public function __call(string $method, array $args): bool |
173 | 173 | { |
174 | 174 | $levelNames = \implode('|', \array_map('ucfirst', \array_keys($this->levelMap))); |
175 | - if (\preg_match('/(.*)(' . $levelNames . ')(.*)/', $method, $matches) > 0) { |
|
176 | - $genericMethod = $matches[1] . ($matches[3] !== 'Records' ? 'Record' : '') . $matches[3]; |
|
175 | + if (\preg_match('/(.*)('.$levelNames.')(.*)/', $method, $matches) > 0) { |
|
176 | + $genericMethod = $matches[1].($matches[3] !== 'Records' ? 'Record' : '').$matches[3]; |
|
177 | 177 | $callable = [$this, $genericMethod]; |
178 | 178 | $level = $this->levelMap[\strtolower($matches[2])]; |
179 | 179 | if (\is_callable($callable)) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - throw new \BadMethodCallException('Call to undefined method ' . static::class . '::' . $method . '()'); |
|
186 | + throw new \BadMethodCallException('Call to undefined method '.static::class.'::'.$method.'()'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | public function reset(): void |