Search
 
SCRIPT & CODE EXAMPLE
 

PHP

What is the purpose of an 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();
}
Comment

PREVIOUS NEXT
Code Example
Php :: view blade not found in laravel 
Php :: php array in variable 
Php :: mail laravel 
Php :: connect to ftp server php 
Php :: oop php 
Php :: Warning: password_verify() expects parameter 2 to be string, array given in 
Php :: php curl get body response 
Php :: attach one or multiple files laravel mail 
Php :: how to run a php file using 
Php :: connect php to db 
Php :: php spreadsheet styles 
Php :: php strings 
Php :: laravel validation rule 
Php :: Redirect with named route in Laravel 
Php :: laravel available router methods 
Php :: relations in php laravel 
Php :: what is actullay work model in laravel 
Php :: Symfony Expected argument of type "string", "null" given 
Php :: php mail merge docx document 
Php :: Mixed int and string keys 
Php :: php get non unique values from array 
Php :: php run cron evey hour 
Php :: php auto reset score 
Php :: laravel postgres deadlock 
Php :: expiry date alert in php 
Php :: Everything inside a pair 
Php :: parameterize constructor mpdf php 
Php :: codeigniter AES _ENCRYPT or AES_DECRYPT in where 
Php :: Find template serving current page 
Php :: Convert Shamsi Jalali Persian Date TimeStamp 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =