RubtsovAV/serps-long-execution

View on GitHub
src/Core/Client/Factory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace RubtsovAV\Serps\Core\Client;

use RubtsovAV\Serps\Core\Exception\ClientNotFoundException;

class Factory
{
    const CLIENT_NAMESPACE = 'RubtsovAV\\Serps\\Client\\';

    public static function getClientInstanceByName($clientName, array $clientConfig = [])
    {
        $clientClassName = static::CLIENT_NAMESPACE . $clientName;
        if (!class_exists($clientClassName)) {
            throw new ClientNotFoundException(
                "client with the name '$clientName' is not found"
            );
        }
        return new $clientClassName($clientConfig);
    }
}