Files
coruna-lab/app/Services/Chain/ChainManager.php
T
2026-09-23 14:26:38 +08:00

27 lines
688 B
PHP

<?php
namespace App\Services\Chain;
use InvalidArgumentException;
class ChainManager
{
public function __construct(
private readonly TronDriver $tron,
private readonly EthDriver $eth,
private readonly BtcDriver $btc,
private readonly SolDriver $sol,
) {}
public function resolve(string $chain): ChainDriver
{
return match (strtolower($chain)) {
'tron', 'trx' => $this->tron,
'eth', 'ethereum' => $this->eth,
'btc', 'bitcoin' => $this->btc,
'sol', 'solana' => $this->sol,
default => throw new InvalidArgumentException("Unsupported chain: {$chain}"),
};
}
}