Sonata\Exporter\Writer\FormattedBoolWriter::write PHP Method

write() public method

public write ( array $data )
$data array
    public function write(array $data)
    {
        foreach ($data as $key => $value) {
            if (is_bool($data[$key])) {
                $data[$key] = $data[$key] === true ? $this->trueLabel : $this->falseLabel;
            }
        }
        $this->writer->write($data);
    }

Usage Example

 public function testValidDataFormat()
 {
     $data = array('john', 'doe', false, true);
     $expected = array('john', 'doe', 'no', 'yes');
     $mock = $this->getMockBuilder('Sonata\\Exporter\\Writer\\XlsWriter')->setConstructorArgs(array('formatedbool.xls', false))->getMock();
     $mock->expects($this->any())->method('write')->with($this->equalTo($expected));
     $writer = new FormattedBoolWriter($mock, $this->trueLabel, $this->falseLabel);
     $writer->open();
     $writer->write($data);
     $writer->close();
 }