clientId)) { throw new \InvalidArgumentException('Spotify Client ID cannot be empty'); } if (empty($this->clientSecret)) { throw new \InvalidArgumentException('Spotify Client Secret cannot be empty'); } if (empty($this->redirectUri) || !filter_var($this->redirectUri, FILTER_VALIDATE_URL)) { throw new \InvalidArgumentException('Spotify Redirect URI must be a valid URL'); } } public static function fromEnvironment(array $env): self { return new self( clientId: $env['SPOTIFY_CLIENT_ID'] ?? '', clientSecret: $env['SPOTIFY_CLIENT_SECRET'] ?? '', redirectUri: $env['SPOTIFY_REDIRECT_URI'] ?? '' ); } public function toArray(): array { return [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, ]; } }