diff --git a/Creational/StaticFactory/StaticFactory.php b/Creational/StaticFactory/StaticFactory.php index 8ebff07..e63b369 100644 --- a/Creational/StaticFactory/StaticFactory.php +++ b/Creational/StaticFactory/StaticFactory.php @@ -14,12 +14,10 @@ final class StaticFactory { public static function factory(string $type): Formatter { - if ($type == 'number') { - return new FormatNumber(); - } elseif ($type == 'string') { - return new FormatString(); - } - - throw new InvalidArgumentException('Unknown format given'); + return match($type) { + 'number' => new FormatNumber(), + 'string' => new FormatString(), + default => throw new InvalidArgumentException('Unknown format given'), + }; } }