Was ist der Zweck eines Abstract?
abstract class AbstractDonater
{
public function donateMinimum(): void
{
// this method can be complex
$minimum = 10;
$this->donate($minimum)
}
abstract protected function donate(int $money);
}
class ConcreteDonaterOne
{
protected function donate(int $money)
{
$donateProvider = new PlayPal();
$donateProvider->pay($money);
}
}
class ConcreteDonaterTwo
{
protected function donate(int $money)
{
$donateProvider = new Scribe();
$donateProvider->transfer($money);
}
}
$donaters = [
new ConcreteDonaterOne(),
new ConcreteDonaterTwo(),
];
foreach ($donaters as $donater)
{
$donater->donateMinimum();
}
Clumsy Chinchilla