| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class Logger implements LoggerInterface |
||
| 14 | { |
||
| 15 | /** @var array<string, array<string, array<Log>>> */ |
||
| 16 | private array $logs = []; |
||
| 17 | |||
| 18 | public function log(MethodInvocation $invocation): mixed |
||
| 19 | { |
||
| 20 | $t = microtime(true); |
||
| 21 | /** @psalm-suppress MixedAssignment */ |
||
| 22 | $result = $invocation->proceed(); |
||
| 23 | $time = microtime(true) - $t; |
||
| 24 | $parent = (new ReflectionClass($invocation->getThis()))->getParentClass(); |
||
| 25 | assert($parent instanceof ReflectionClass); |
||
| 26 | $class = $parent->getName(); |
||
| 27 | $method = $invocation->getMethod()->getName(); |
||
| 28 | $this->logs[$class][$method][] = new Log( |
||
| 29 | (array) $invocation->getArguments(), |
||
| 30 | (array) $invocation->getNamedArguments(), |
||
| 31 | $result, |
||
| 32 | $time, |
||
| 33 | ); |
||
| 34 | |||
| 35 | return $result; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param class-string $class |
||
|
|
|||
| 40 | * |
||
| 41 | * @return array<Log> |
||
| 42 | */ |
||
| 43 | public function getLogs(string $class, string $method): array |
||
| 50 | } |
||
| 51 | } |
||
| 52 |