<?php
interface Table {
public function getTableName();
}
class TableA implements Table {
public function getTableName() {
return 'TableA';
}
}
class TableB implements Table {
public function getTableName() {
return 'TableB';
}
}
class TableC implements Table {
public function getTableName() {
return 'TableC';
}
}
class TableD implements Table {
public function getTableName() {
return 'TableD';
}
}
class Service {
public $tableA;
public $tableB;
public $tableC;
public $tableD;
public function __construct(Table $a, Table $b, Table $c, Table $d) {
$this->tableA = $a;
$this->tableB = $b;
$this->tableC = $c;
$this->tableD = $d;
}
public function table_A_and_B_doSomething() {
echo $this->tableA->getTableName(), ' ', $this->tableB->getTableName();
}
public function table_C_and_D_doSomething() {
echo $this->tableC->getTableName(), ' ', $this->tableD->getTableName();
}
}
$service = new Service(new tableA(), new tableB(), new tableC(), new tableD());
$service->table_C_and_D_doSomething();