| @@ 8-26 (lines=19) @@ | ||
| 5 | use Gettext\Translations; |
|
| 6 | use Gettext\Utils\MultidimensionalArrayTrait; |
|
| 7 | ||
| 8 | class Json extends Generator implements GeneratorInterface |
|
| 9 | { |
|
| 10 | use MultidimensionalArrayTrait; |
|
| 11 | ||
| 12 | public static $options = [ |
|
| 13 | 'json' => 0, |
|
| 14 | 'includeHeaders' => false, |
|
| 15 | ]; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * {@inheritdoc} |
|
| 19 | */ |
|
| 20 | public static function toString(Translations $translations, array $options = []) |
|
| 21 | { |
|
| 22 | $options += static::$options; |
|
| 23 | ||
| 24 | return json_encode(self::toArray($translations, $options['includeHeaders'], true), $options['json']); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||
| @@ 8-26 (lines=19) @@ | ||
| 5 | use Gettext\Translations; |
|
| 6 | use Gettext\Utils\DictionaryTrait; |
|
| 7 | ||
| 8 | class JsonDictionary extends Generator implements GeneratorInterface |
|
| 9 | { |
|
| 10 | use DictionaryTrait; |
|
| 11 | ||
| 12 | public static $options = [ |
|
| 13 | 'json' => 0, |
|
| 14 | 'includeHeaders' => false, |
|
| 15 | ]; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * {@parentDoc}. |
|
| 19 | */ |
|
| 20 | public static function toString(Translations $translations, array $options = []) |
|
| 21 | { |
|
| 22 | $options += static::$options; |
|
| 23 | ||
| 24 | return json_encode(self::toArray($translations, $options['includeHeaders']), $options['json']); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||