mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 04:00:18 +02:00
Abstract factory (#366)
* rewrite of the Abstract Factory pattern * update composer deps * fixed argument to json_encode which cannot be null
This commit is contained in:
17
Creational/AbstractFactory/UnixJsonWriter.php
Normal file
17
Creational/AbstractFactory/UnixJsonWriter.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\AbstractFactory;
|
||||
|
||||
class UnixJsonWriter implements JsonWriter
|
||||
{
|
||||
public function write(array $data, bool $formatted): string
|
||||
{
|
||||
$options = 0;
|
||||
|
||||
if ($formatted) {
|
||||
$options = JSON_PRETTY_PRINT;
|
||||
}
|
||||
|
||||
return json_encode($data, $options);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user