diff --git a/src/RedsysClient.php b/src/RedsysClient.php index b198c00..39c4e13 100644 --- a/src/RedsysClient.php +++ b/src/RedsysClient.php @@ -24,35 +24,21 @@ public function __construct( public function getBaseUrl(): string { - if ($this->environment === Environment::Production) { - return 'https://sis.redsys.es/sis'; - } - - if ($this->environment === Environment::Test) { - return 'https://sis-t.redsys.es:25443/sis'; - } - - if ($this->environment === Environment::Custom) { - return $this->customBaseUrl; - } - - throw new \Exception('Redsys undefined environment'); + return match($this->environment) { + Environment::Production => 'https://sis.redsys.es/sis', + Environment::Test => 'https://sis-t.redsys.es:25443/sis', + Environment::Custom => $this->customBaseUrl, + default => throw new \Exception('Redsys undefined environment'), + }; } public function getRestBaseUrl(): string { - if ($this->environment === Environment::Production) { - return 'https://sis.redsys.es/sis/rest'; - } - - if ($this->environment === Environment::Test) { - return 'https://sis-t.redsys.es:25443/sis/rest'; - } - - if ($this->environment === Environment::Custom) { - return $this->customBaseUrl; - } - - throw new \Exception('Redsys undefined environment'); + return match ($this->environment) { + Environment::Production => 'https://sis.redsys.es/sis/rest', + Environment::Test => 'https://sis-t.redsys.es:25443/sis/rest', + Environment::Custom => $this->customBaseUrl, + default => throw new \Exception('Redsys undefined environment'), + }; } }