mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 00:46:38 +02:00
update deps & install rector
This commit is contained in:
@@ -2,17 +2,14 @@
|
||||
|
||||
namespace DesignPatterns\Creational\StaticFactory;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Note1: Remember, static means global state which is evil because it can't be mocked for tests
|
||||
* Note2: Cannot be subclassed or mock-upped or have multiple different instances.
|
||||
*/
|
||||
final class StaticFactory
|
||||
{
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return Formatter
|
||||
*/
|
||||
public static function factory(string $type): Formatter
|
||||
{
|
||||
if ($type == 'number') {
|
||||
@@ -21,6 +18,6 @@ final class StaticFactory
|
||||
return new FormatString();
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Unknown format given');
|
||||
throw new InvalidArgumentException('Unknown format given');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user