AsgardCms/Workshop

View on GitHub
Scaffold/Theme/ThemeGeneratorFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php namespace Modules\Workshop\Scaffold\Theme;

use Modules\Workshop\Scaffold\Theme\Exceptions\FileTypeNotFoundException;
use Modules\Workshop\Scaffold\Theme\FileTypes\FileType;

class ThemeGeneratorFactory
{
    /**
     * @param string $file
     * @param array $options
     * @return FileType
     * @throws FileTypeNotFoundException
     */
    public function make($file, array $options)
    {
        $class = 'Modules\Workshop\Scaffold\Theme\FileTypes\\' . ucfirst($file);

        if (! class_exists($class)) {
            throw new FileTypeNotFoundException();
        }

        return new $class($options);
    }
}