use constant instead of string

This commit is contained in:
Trismegiste
2013-05-10 21:29:43 +02:00
parent cc765bde41
commit d4ae3bcd8f
5 changed files with 44 additions and 15 deletions

View File

@@ -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");
}