cs StaticFactory

This commit is contained in:
Dominik Liebler
2013-09-12 11:43:30 +02:00
parent 3808eab0a0
commit daac491ef0
6 changed files with 164 additions and 141 deletions

View File

@@ -2,7 +2,10 @@
namespace DesignPatterns\StaticFactory;
class FormatNumber implements Formatter
/**
* Class FormatNumber
*/
class FormatNumber implements FormatterInterface
{
}

View File

@@ -2,7 +2,10 @@
namespace DesignPatterns\StaticFactory;
class FormatString implements Formatter
/**
* Class FormatString
*/
class FormatString implements FormatterInterface
{
}

View File

@@ -2,7 +2,10 @@
namespace DesignPatterns\StaticFactory;
interface Formatter
/**
* Class FormatterInterface
*/
interface FormatterInterface
{
}

View File

@@ -14,16 +14,19 @@ namespace DesignPatterns\StaticFactory;
* - Zend Framework: Zend_Cache_Backend or _Frontend use a factory method create cache backends or frontends
*
* Note1: Remember, static => global => evil
* Note2: Cannot be subclassed or mock-uped or have multiple different instances
* Note2: Cannot be subclassed or mock-upped or have multiple different instances
*/
class StaticFactory
{
/**
* the parametrized function to get create an instance
*
* @param string $type
*
* @static
* @return Formatter
*
* @throws \InvalidArgumentException
* @return FormatterInterface
*/
public static function factory($type)
{
@@ -35,5 +38,4 @@ class StaticFactory
return new $className();
}
}