Pagekit\View\Asset\AssetFactory::create PHP Method

create() public method

Create an asset instance.
public create ( string $name, mixed $source, mixed $dependencies = [], mixed $options = [] ) : Pagekit\View\Asset\AssetInterface
$name string
$source mixed
$dependencies mixed
$options mixed
return Pagekit\View\Asset\AssetInterface
    public function create($name, $source, $dependencies = [], $options = [])
    {
        if (is_string($dependencies)) {
            $dependencies = [$dependencies];
        }
        if (is_string($options)) {
            $options = ['type' => $options];
        }
        if (!isset($options['type'])) {
            $options['type'] = 'file';
        }
        if ($options['type'] === 'file' && !isset($options['version'])) {
            $options['version'] = $this->version;
        }
        if (isset($this->types[$options['type']])) {
            $class = $this->types[$options['type']];
            return new $class($name, $source, $dependencies, $options);
        }
        throw new \InvalidArgumentException('Unable to determine asset type.');
    }