mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 09:12:34 +01:00
27 lines
579 B
PHP
27 lines
579 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\FactoryMethod;
|
|
|
|
/**
|
|
* ItalianFactory is vehicle factory in Italy
|
|
*/
|
|
class ItalianFactory extends FactoryMethod
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function createVehicle($type)
|
|
{
|
|
switch ($type) {
|
|
case parent::CHEAP:
|
|
return new Bicycle();
|
|
break;
|
|
case parent::FAST:
|
|
return new Ferrari();
|
|
break;
|
|
default:
|
|
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
|
}
|
|
}
|
|
}
|