<?php declare(strict_types=1);

namespace Neusta\IntexClient\Connection;

use Neusta\IntexClient\Connection\Model\Connection;

use function class_exists;
use function sprintf;
use function ucwords;
use function strtolower;

class Factory
{
    public static function create(string $connectionType): Connection
    {
        $connectionPath = sprintf(
            '\Neusta\IntexClient\Model\Connection\%sConnection',
            ucwords(strtolower($connectionType))
        );

        if (class_exists($connectionPath)) {
            return new $connectionPath();
        }

        throw new \RuntimeException('Invalid Connection Type given');
    }
}
