From 882dd7048759345af3537c914e34604a2c8295b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 6 Dec 2020 17:45:35 -0300 Subject: [PATCH] Added AliasFactory --- src/AliasFactory.php | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/AliasFactory.php diff --git a/src/AliasFactory.php b/src/AliasFactory.php new file mode 100644 index 0000000..b6f6f91 --- /dev/null +++ b/src/AliasFactory.php @@ -0,0 +1,48 @@ + + * @license https://opensource.org/licenses/MIT MIT License + */ +namespace CoiSA\Factory; + +/** + * Class AliasFactory. + * + * @package CoiSA\Factory + */ +final class AliasFactory implements FactoryInterface +{ + /** + * @var string + */ + private $factoryAlias; + + /** + * AliasFactory constructor. + * + * @param string $factoryAlias + */ + public function __construct($factoryAlias) + { + $this->factoryAlias = $factoryAlias; + } + + /** + * {@inheritdoc} + */ + public function create() + { + $arguments = \func_get_args(); + $factory = AbstractFactory::getFactory($this->factoryAlias); + + return \call_user_func_array(array($factory, 'create'), $arguments); + } +}