mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-16 12:56:21 +02:00
20 lines
395 B
PHP
20 lines
395 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\FactoryMethod;
|
|
|
|
abstract class FactoryMethod
|
|
{
|
|
const CHEAP = 'cheap';
|
|
const FAST = 'fast';
|
|
|
|
abstract protected function createVehicle(string $type): VehicleInterface;
|
|
|
|
public function create(string $type): VehicleInterface
|
|
{
|
|
$obj = $this->createVehicle($type);
|
|
$obj->setColor('black');
|
|
|
|
return $obj;
|
|
}
|
|
}
|