29 lines
585 B
PHP
29 lines
585 B
PHP
![]() |
<?php
|
||
|
|
||
|
namespace Modules\Options\Repository;
|
||
|
|
||
|
use Exception;
|
||
|
use Illuminate\Support\Str;
|
||
|
|
||
|
class Factory
|
||
|
{
|
||
|
/**
|
||
|
* make
|
||
|
* @param string $optionName
|
||
|
* @return OptionInterface
|
||
|
* @throws Exception
|
||
|
*/
|
||
|
public function make(string $optionName): OptionInterface
|
||
|
{
|
||
|
$className = __NAMESPACE__.'\\'.Str::of($optionName)->ucfirst()->toString();
|
||
|
|
||
|
$class = new $className();
|
||
|
|
||
|
if (! $class instanceof OptionInterface) {
|
||
|
throw new Exception('option must be implement [OptionInterface]');
|
||
|
}
|
||
|
|
||
|
return $class;
|
||
|
}
|
||
|
}
|