public function testDecoderWithDecorators()
    {
        $decorator = new DefaultConcreteDecorator();
        $this->decoder->getDecoder()->setValueDecorator(new StrToUpperDecorator($decorator));
        $this->assertSame(['@attributes' => ['name' => 'JOHN', 'surname' => 'DOE'], 'foo' => 'BAR'], $this->decoder->decode('<?xml version="1.0" encoding="utf-8"?>
<Document name="John" surname="Doe"><foo>bar</foo></Document>'));
    }
Exemple #2
0
 /**
  * Decode xml to array
  *
  * @param string $xml
  * @return mixed
  * @throws Exception
  */
 function xml_decode($xml)
 {
     $decoder = new XmlDecoder(new ToArrayDecoder());
     return $decoder->decode($xml);
 }