mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 15:06:31 +02:00
refactored Factory Method pattern
This commit is contained in:
21
Creational/FactoryMethod/FileLoggerFactory.php
Normal file
21
Creational/FactoryMethod/FileLoggerFactory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\FactoryMethod;
|
||||
|
||||
class FileLoggerFactory implements LoggerFactory
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $filePath;
|
||||
|
||||
public function __construct(string $filePath)
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
}
|
||||
|
||||
public function createLogger(): Logger
|
||||
{
|
||||
return new FileLogger($this->filePath);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user