/** * */ public function testEncodingWithDecorator() { $decorator = new \Bebnev\Pattern\Decorator\DefaultConcreteDecorator(); $decorator = new StrToUpperDecorator($decorator); $xml = new XmlEncoder(new FromArrayEncoder(), $decorator); $this->assertSame(preg_replace('/\\r\\n/', "\n", '<?xml version="1.0" encoding="utf-8"?> <Document><asd>X</asd></Document>'), $xml->encode(['Document' => ['asd' => 'x']])); }
/** * Array to Xml encode * * @param array $data * @return mixed */ function array_to_xml_encode(array $data) { $xml = new XmlEncoder(new FromArrayEncoder()); return $xml->encode($data); }