Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/serializer/Encoder/YamlEncoder.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
24 { | 24 { |
25 const FORMAT = 'yaml'; | 25 const FORMAT = 'yaml'; |
26 | 26 |
27 private $dumper; | 27 private $dumper; |
28 private $parser; | 28 private $parser; |
29 private $defaultContext = array('yaml_inline' => 0, 'yaml_indent' => 0, 'yaml_flags' => 0); | 29 private $defaultContext = ['yaml_inline' => 0, 'yaml_indent' => 0, 'yaml_flags' => 0]; |
30 | 30 |
31 public function __construct(Dumper $dumper = null, Parser $parser = null, array $defaultContext = array()) | 31 public function __construct(Dumper $dumper = null, Parser $parser = null, array $defaultContext = []) |
32 { | 32 { |
33 if (!class_exists(Dumper::class)) { | 33 if (!class_exists(Dumper::class)) { |
34 throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Install "symfony/yaml" to use it.'); | 34 throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Install "symfony/yaml" to use it.'); |
35 } | 35 } |
36 | 36 |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
43 * {@inheritdoc} | 43 * {@inheritdoc} |
44 */ | 44 */ |
45 public function encode($data, $format, array $context = array()) | 45 public function encode($data, $format, array $context = []) |
46 { | 46 { |
47 $context = array_merge($this->defaultContext, $context); | 47 $context = array_merge($this->defaultContext, $context); |
48 | 48 |
49 return $this->dumper->dump($data, $context['yaml_inline'], $context['yaml_indent'], $context['yaml_flags']); | 49 return $this->dumper->dump($data, $context['yaml_inline'], $context['yaml_indent'], $context['yaml_flags']); |
50 } | 50 } |
58 } | 58 } |
59 | 59 |
60 /** | 60 /** |
61 * {@inheritdoc} | 61 * {@inheritdoc} |
62 */ | 62 */ |
63 public function decode($data, $format, array $context = array()) | 63 public function decode($data, $format, array $context = []) |
64 { | 64 { |
65 $context = array_merge($this->defaultContext, $context); | 65 $context = array_merge($this->defaultContext, $context); |
66 | 66 |
67 return $this->parser->parse($data, $context['yaml_flags']); | 67 return $this->parser->parse($data, $context['yaml_flags']); |
68 } | 68 } |