/** * @param Employee $employee * * @return mixed */ public function calculateSalary(Employee $employee) { return $employee->getHourlyRate() * self::FULLTIME_HOURS * self::MONTHLY_WORKING_DAYS; } } /** * Class PartTimePayment */ class PartTimePayment extends AbstractSalaryStrategy { /** * @param Employee $employee * * @return mixed */ public function calculateSalary(Employee $employee) { return $employee->getHourlyRate() * self::PARTTIME_HOURS * self::MONTHLY_WORKING_DAYS; } } $john = new Developer(new FullTimePayment()); echo $john->getSalary(); //1080 $martha = new QualityAnalyst(new PartTimePayment()); echo $martha->getSalary(); //642