File "GeneratorFactory.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/woo-license-keys/vendor/gladcodes/keygen/src/Keygen/GeneratorFactory.php
File
size: 872 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
/*
* This file is part of the Keygen package.
*
* (c) Glad Chinda <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Keygen;
use InvalidArgumentException;
class GeneratorFactory
{
/**
* Create a generator instance from the specified type.
*
* @param string $type Generator type.
* @return Keygen\Generator
*
* @throws \InvalidArgumentException
*/
public static function create($type)
{
$generator = sprintf("Keygen\Generators\%sGenerator", ucfirst($type));
if (class_exists($generator)) {
$generator = new $generator;
if ($generator instanceof Generator) {
return $generator;
}
}
throw new InvalidArgumentException('Cannot create unknown generator type.');
}
}