mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-21 08:47:37 +02:00
29 lines
549 B
PHP
29 lines
549 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\NullObject;
|
|
|
|
class Service
|
|
{
|
|
/**
|
|
* @var LoggerInterface
|
|
*/
|
|
private $logger;
|
|
|
|
/**
|
|
* @param LoggerInterface $logger
|
|
*/
|
|
public function __construct(LoggerInterface $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__);
|
|
}
|
|
}
|