1
0
mirror of synced 2024-11-27 15:56:06 +03:00
api-client-php/tests/utils/ArrayLogger.php

61 lines
1.1 KiB
PHP
Raw Normal View History

2021-06-02 17:00:32 +03:00
<?php
/**
* PHP version 7.3
*
* @category ArrayLogger
* @package RetailCrm\TestUtils
*/
namespace RetailCrm\TestUtils;
use Psr\Log\AbstractLogger;
/**
* Class ArrayLogger
*
* @category ArrayLogger
* @package RetailCrm\TestUtils
*/
class ArrayLogger extends AbstractLogger
{
/** @var string[][] */
private $messages = [];
/**
* @return string[][]
*/
public function getMessages(): array
{
return $this->messages;
}
/**
* @return string[]
*/
public function getLastMessage(): array
{
return count($this->messages) > 0 ? end($this->messages) : [];
}
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
*
* @return void
*
* @throws \Psr\Log\InvalidArgumentException
*/
2021-12-16 17:06:14 +03:00
public function log($level, $message, array $context = array()): void
2021-06-02 17:00:32 +03:00
{
$this->messages[] = [
'level' => $level,
'message' => $message,
'context' => $context,
];
}
}