| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 27 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 15 | public function serialize($data): string | ||
| 16 |     { | ||
| 17 | $normalizers = [ | ||
| 18 | new DateTimeNormalizer(), | ||
| 19 | new ObjectNormalizer(), | ||
| 20 | ]; | ||
| 21 | |||
| 22 | $encoders = [ | ||
| 23 | new YamlEncoder(), | ||
| 24 | ]; | ||
| 25 | |||
| 26 | $serializer = new Serializer($normalizers, $encoders); | ||
| 27 | |||
| 28 | // The Symfony serialized doesn't support `stdClass` yet. | ||
| 29 | // This may be removed when Symfony 5.1 is released. | ||
| 30 |         if ($data instanceof \stdClass) { | ||
| 31 | $data = (array) $data; | ||
| 32 | } | ||
| 33 | |||
| 34 | return $this->dedent( | ||
| 35 | $serializer->serialize($data, 'yaml', [ | ||
| 36 | 'yaml_inline' => 2, | ||
| 37 | 'yaml_indent' => 4, | ||
| 38 | 'yaml_flags' => Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK, | ||
| 39 | ]) | ||
| 40 | ); | ||
| 41 | } | ||
| 42 | |||
| 58 |