Doctrine\OXM\Marshaller\XmlMarshaller::setEncoding PHP Method

setEncoding() public method

public setEncoding ( string $encoding ) : void
$encoding string
return void
    public function setEncoding($encoding)
    {
        $this->encoding = strtoupper($encoding);
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function itShouldSupportMarshallingToOtherEncodings()
 {
     $simple = new SimpleChild();
     $this->marshaller->setEncoding('ISO-8859-1');
     $xml = $this->marshaller->marshalToString($simple);
     $this->assertTrue(strlen($xml) > 0);
     $this->assertXmlStringEqualsXmlString('<?xml version="1.0" encoding="ISO-8859-1"?><simple-child><other>yes</other></simple-child>', $xml);
     $obj = $this->marshaller->unmarshalFromString($xml);
     $this->assertEquals('yes', $obj->other);
 }