| @@ 9-28 (lines=20) @@ | ||
| 6 | use Gettext\Utils\MultidimensionalArrayTrait; |
|
| 7 | use Symfony\Component\Yaml\Yaml as YamlDumper; |
|
| 8 | ||
| 9 | class Yaml extends Generator implements GeneratorInterface |
|
| 10 | { |
|
| 11 | use MultidimensionalArrayTrait; |
|
| 12 | ||
| 13 | public static $options = [ |
|
| 14 | 'includeHeaders' => false, |
|
| 15 | 'indent' => 2, |
|
| 16 | 'inline' => 4, |
|
| 17 | ]; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * {@inheritdoc} |
|
| 21 | */ |
|
| 22 | public static function toString(Translations $translations, array $options = []) |
|
| 23 | { |
|
| 24 | $options += static::$options; |
|
| 25 | ||
| 26 | return YamlDumper::dump( |
|
| 27 | self::toArray($translations, $options['includeHeaders']), |
|
| 28 | $options['inline'], |
|
| 29 | $options['indent'] |
|
| 30 | ); |
|
| 31 | } |
|
| @@ 9-28 (lines=20) @@ | ||
| 6 | use Gettext\Utils\DictionaryTrait; |
|
| 7 | use Symfony\Component\Yaml\Yaml as YamlDumper; |
|
| 8 | ||
| 9 | class YamlDictionary extends Generator implements GeneratorInterface |
|
| 10 | { |
|
| 11 | use DictionaryTrait; |
|
| 12 | ||
| 13 | public static $options = [ |
|
| 14 | 'includeHeaders' => false, |
|
| 15 | 'indent' => 2, |
|
| 16 | 'inline' => 3, |
|
| 17 | ]; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * {@inheritdoc} |
|
| 21 | */ |
|
| 22 | public static function toString(Translations $translations, array $options = []) |
|
| 23 | { |
|
| 24 | $options += static::$options; |
|
| 25 | ||
| 26 | return YamlDumper::dump( |
|
| 27 | self::toArray($translations, $options['includeHeaders']), |
|
| 28 | $options['inline'], |
|
| 29 | $options['indent'] |
|
| 30 | ); |
|
| 31 | } |
|