This commit is contained in:
Dominik Liebler 2013-09-12 11:46:14 +02:00
parent daac491ef0
commit ec6ed14767
5 changed files with 17 additions and 11 deletions

View File

@ -24,7 +24,7 @@ class GermanFactory extends FactoryMethod
return $obj;
break;
default :
default:
throw new \InvalidArgumentException("$type is not a valid vehicle");
}
}

View File

@ -19,7 +19,7 @@ class ItalianFactory extends FactoryMethod
case parent::FAST:
return new Ferrari();
break;
default :
default:
throw new \InvalidArgumentException("$type is not a valid vehicle");
}
}

View File

@ -40,7 +40,9 @@ class Singleton
*
*/
private function __construct()
{}
{
}
/**
* prevent the instance from being cloned
@ -48,7 +50,9 @@ class Singleton
* @return void
*/
private function __clone()
{}
{
}
/**
* prevent from being unserialized
@ -56,5 +60,7 @@ class Singleton
* @return void
*/
private function __wakeup()
{}
{
}
}

View File

@ -1,8 +1,8 @@
<?php
spl_autoload_register(function ($class) {
if (preg_match('#^DesignPatterns\\\\(.+)$#', $class, $ret)) {
$relPath = str_replace('\\', DIRECTORY_SEPARATOR, $ret[1]);
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . $relPath . '.php';
}
});
if (preg_match('#^DesignPatterns\\\\(.+)$#', $class, $ret)) {
$relPath = str_replace('\\', DIRECTORY_SEPARATOR, $ret[1]);
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . $relPath . '.php';
}
});