думаю не много не так реализовали, вот если:
$driver = new XLSXExporter();
$exporter = new DataExporter($driver);
echo $exporter->getResult();
class DataExporter{
protected $driver;
function __construct(DriverExporterInterface $driver){
$this->driver = $driver;
}
function getResult(){
return $this->driver->process();
}
}
interface DriverExporterInterface{
public function process();
}
получается:
if( $format == 'XLSX' ) {
$driver = new XLSXExporter();
$driver->setColumnWidth( 0, 100 );
$driver->setColumnWidth( 1, 30 );
$driver->setColumnWidth( 2, 60 );
}
else{
$driver = new EmptyExporter();
}
$exporter = new DataExporter($driver);
$exporter->setData( $data );
echo $exporter->getResult();