25 lines
604 B
PHP
25 lines
604 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,
|
|
) {}
|
|
|
|
public function resolve(string $chain): ChainDriver
|
|
{
|
|
return match (strtolower($chain)) {
|
|
'tron', 'trx' => $this->tron,
|
|
'eth', 'ethereum' => $this->eth,
|
|
'btc', 'bitcoin' => $this->btc,
|
|
default => throw new InvalidArgumentException("Unsupported chain: {$chain}"),
|
|
};
|
|
}
|
|
}
|