for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\MediaLibrary\PathGenerator;
use Spatie\MediaLibrary\Exceptions\InvalidPathGenerator;
class PathGeneratorFactory
{
public static function create()
$pathGeneratorClass = BasePathGenerator::class;
$customPathClass = config('medialibrary.path_generator');
if ($customPathClass) {
$pathGeneratorClass = $customPathClass;
}
static::guardAgainstInvalidPathGenerator($pathGeneratorClass);
return app($pathGeneratorClass);
protected static function guardAgainstInvalidPathGenerator(string $pathGeneratorClass)
if (! class_exists($pathGeneratorClass)) {
throw InvalidPathGenerator::doesntExist($pathGeneratorClass);
if (! is_subclass_of($pathGeneratorClass, PathGenerator::class)) {
is_subclass_of
\Spatie\MediaLibrary\Pat...or\PathGenerator::class
ReflectionClass::implementsInterface
throw InvalidPathGenerator::isntAPathGenerator($pathGeneratorClass);