Files
coruna-lab/app/Services/Chain/ChainManager.php
T
2026-09-26 12:27:12 +08:00

29 lines
780 B
PHP

<?php
namespace App\Services\Chain;
use InvalidArgumentException;
class ChainManager
{
public function __construct(
private readonly TronDriver $tron,
private readonly EthDriver $eth,
private readonly BscDriver $bsc,
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,
'bsc', 'bnb', 'binance' => $this->bsc,
'btc', 'bitcoin' => $this->btc,
'sol', 'solana' => $this->sol,
default => throw new InvalidArgumentException("Unsupported chain: {$chain}"),
};
}
}