25 lines
570 B
PHP
25 lines
570 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Lvl0\FediDiscover\Clients;
|
||
|
|
|
||
|
|
use Lvl0\FediDiscover\Config\InstanceType;
|
||
|
|
use Lvl0\FediDiscover\Models\Instance;
|
||
|
|
|
||
|
|
class FediverseClientFactory
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private MastodonClient $mastodonClient,
|
||
|
|
private LemmyClient $lemmyClient,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
public function for(Instance $instance): FediverseClientInterface
|
||
|
|
{
|
||
|
|
return match ($instance->type) {
|
||
|
|
InstanceType::Mastodon => $this->mastodonClient,
|
||
|
|
InstanceType::Lemmy => $this->lemmyClient,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|