mirror of
https://github.com/friendica/friendica
synced 2025-01-19 12:19:46 +00:00
LoggerFactory returns same object
This commit is contained in:
parent
9bcb470caa
commit
4a8533aa11
2 changed files with 14 additions and 1 deletions
|
@ -17,8 +17,14 @@ use Psr\Log\NullLogger;
|
|||
*/
|
||||
final class LoggerFactory
|
||||
{
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function create(): LoggerInterface
|
||||
{
|
||||
return new NullLogger();
|
||||
if (! isset($this->logger)) {
|
||||
$this->logger = new NullLogger();
|
||||
}
|
||||
|
||||
return $this->logger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,4 +21,11 @@ class LoggerFactoryTest extends TestCase
|
|||
|
||||
$this->assertInstanceOf(LoggerInterface::class, $factory->create());
|
||||
}
|
||||
|
||||
public function testLoggerFactoryCreateReturnsSameObject(): void
|
||||
{
|
||||
$factory = new LoggerFactory();
|
||||
|
||||
$this->assertSame($factory->create(), $factory->create());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue