mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
use constant instead of string
This commit is contained in:
@@ -18,12 +18,15 @@ class ItalianFactory extends FactoryMethod
|
||||
protected function createVehicle($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'cheap' :
|
||||
|
||||
case parent::CHEAP :
|
||||
return new Bicycle();
|
||||
break;
|
||||
case '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