| Total Complexity | 6 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class SignerConfigProvider |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var array<SignerConfig> |
||
| 23 | */ |
||
| 24 | private array $configs = []; |
||
| 25 | |||
| 26 | private string $defaultGateway = 'default'; |
||
| 27 | |||
| 28 | public function addConfig(SignerConfig $config, string $gateway = 'default'): void |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getConfig(string|null $gateway = null): SignerConfig |
||
| 34 | { |
||
| 35 | if (null === $gateway) { |
||
| 36 | $gateway = $this->defaultGateway; |
||
| 37 | } |
||
| 38 | if (array_key_exists($gateway, $this->configs)) { |
||
| 39 | return $this->configs[$gateway]; |
||
| 40 | } |
||
| 41 | |||
| 42 | throw new InvalidArgumentException( |
||
| 43 | sprintf('Config for gateway "%s" does not exist. You are probably forgot added or you wrong set default config.', $gateway) |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function setDefaultGateway(string $gateway): void |
||
| 48 | { |
||
| 49 | $this->defaultGateway = $gateway; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getDefaultGateway(): string |
||
| 55 | } |
||
| 56 | } |
||
| 57 |