mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 01:02:25 +01:00
* rewrite of the Abstract Factory pattern * update composer deps * fixed argument to json_encode which cannot be null
18 lines
331 B
PHP
18 lines
331 B
PHP
<?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);
|
|
}
|
|
}
|