Files
DesignPatternsPHP/Behavioral/NullObject/Service.php
2019-12-14 13:41:03 +01:00

23 lines
474 B
PHP

<?php declare(strict_types=1);
namespace DesignPatterns\Behavioral\NullObject;
class Service
{
private Logger $logger;
public function __construct(Logger $logger)
{
$this->logger = $logger;
}
/**
* do something ...
*/
public function doSomething()
{
// notice here that you don't have to check if the logger is set with eg. is_null(), instead just use it
$this->logger->log('We are in '.__METHOD__);
}
}