My question is, where do I instantiate an Encoder object? I currently have it wrapped up in the constructor of the main class (Exporter), but I'm not enforcing the interface and it feels a little wrong.
The constructor of my class is below
Code: Select all
public function __construct($tableName, $exportType = 1, $exportDestination = 1, PDO $dbh) {
if(!empty($tableName)) {
$this->tableNames[] = $tableName;
}
$this->exportType = $exportType;
$this->exportDest = $exportDestination;
$this->DB = $dbh;
switch($this->exportType) {
case(self::XML):
$this->encoder = new XMLExportEncoder();
break;
case(self::CSV):
$this->encoder = new CSVExportEncoder();
break;
}