Skip to content

Commit

Permalink
Added AliasFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
coisa committed Dec 6, 2020
1 parent c77dbfa commit 882dd70
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/AliasFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* This file is part of coisa/factory.
*
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*
* @link https://github.com/coisa/factory
*
* @copyright Copyright (c) 2020 Felipe Sayão Lobato Abreu <[email protected]>
* @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);
}
}

0 comments on commit 882dd70

Please sign in to comment.