mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-02 05:00:15 +02:00
cs FactoryMethod
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DesignPatternPHP
|
||||
*/
|
||||
|
||||
namespace DesignPatterns\FactoryMethod;
|
||||
|
||||
/**
|
||||
@@ -11,25 +7,20 @@ namespace DesignPatterns\FactoryMethod;
|
||||
*/
|
||||
class ItalianFactory extends FactoryMethod
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createVehicle($type)
|
||||
{
|
||||
switch ($type) {
|
||||
|
||||
case parent::CHEAP :
|
||||
case parent::CHEAP:
|
||||
return new Bicycle();
|
||||
break;
|
||||
|
||||
case parent::FAST :
|
||||
case parent::FAST:
|
||||
return new Ferrari();
|
||||
break;
|
||||
|
||||
default :
|
||||
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user