Throw exception when registering an invalid source

This commit is contained in:
Andrea Marco Sartori 2022-10-29 17:59:19 +10:00
parent a26ebd8ae8
commit a08a048061

View File

@ -79,11 +79,11 @@ abstract class Source implements IteratorAggregate
public function register(string ...$customSource): void
{
foreach ($customSource as $class) {
if (is_subclass_of($class, Source::class)) {
static::$customSources[] = $class;
if (!is_subclass_of($class, Source::class)) {
throw SourceException::invalidSource($class);
}
throw SourceException::invalidSource($class);
static::$customSources[] = $class;
}
}