for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace SpotifyApiConnect\Domain\Model;
use SpotifyApiConnect\Message;
use RuntimeException;
final class Config implements ConfigInterface
{
/**
* @return string
*/
public function getClientId(): string
$clientId = (string)$this->get('CLIENT_ID');
if (empty($clientId)) {
throw new RuntimeException(
sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_ID')
);
}
return $clientId;
public function getClientSecret(): string
$clientSecret = (string)$this->get('CLIENT_SECRET');
if (empty($clientSecret)) {
sprintf(Message::ERROR_GET_ENV_VARIABLE, 'CLIENT_SECRET')
return $clientSecret;
public function getRedirectUri(): string
$redirectUri = (string)$this->get('REDIRECT_URI');
if (empty($redirectUri)) {
sprintf(Message::ERROR_GET_ENV_VARIABLE, 'REDIRECT_URI')
return $redirectUri;
public function getSpotifyUsername(): string
$spotifyUsername = (string)$this->get('SPOTIFY_USERNAME');
if (empty($spotifyUsername)) {
sprintf(Message::ERROR_GET_ENV_VARIABLE, 'SPOTIFY_USERNAME')
return $spotifyUsername;
* @param string $name
* @return mixed
private function get(string $name)
if (isset($_ENV[$name])) {
return $_ENV[$name];
return getenv($name);