mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-05 06:27:25 +02:00
use constant instead of string
This commit is contained in:
@@ -18,12 +18,19 @@ class GermanFactory extends FactoryMethod
|
||||
protected function createVehicle($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'cheap' :
|
||||
|
||||
case parent::CHEAP :
|
||||
return new Bicycle();
|
||||
break;
|
||||
case 'fast' :
|
||||
return new Porsche();
|
||||
|
||||
case parent::FAST :
|
||||
$obj = new Porsche();
|
||||
// we can specialize the way we want some concrete Vehicle since
|
||||
// we know the class
|
||||
$obj->addTuningAMG();
|
||||
return $obj;
|
||||
break;
|
||||
|
||||
default :
|
||||
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
||||
}
|
||||
|
Reference in New Issue
Block a user