purpose of abstract code example
Example: What is the purpose of an abstract?
abstract class AbstractDonater
{
public function donateMinimum(): void
{
$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();
}