Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Configuration parameter nullable #372

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions swagger-config/marketing/php/templates/Configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Configuration

public function setConfig($config = array())
{
$apiKey = isset($config['apiKey']) ? $config['apiKey'] : '';
$accessToken = isset($config['accessToken']) ? $config['accessToken'] : '';
$server = isset($config['server']) ? $config['server'] : 'invalid-server';
$apiKey = $config['apiKey'] ?? '';
$accessToken = $config['accessToken'] ?? '';
$server = $config['server'] ?? 'invalid-server';
$host = str_replace('server', $server, $this->getHost());

// Basic Authentication
Expand Down Expand Up @@ -74,7 +74,7 @@ class Configuration

public function getApiKey($apiKeyIdentifier)
{
return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null;
return $this->apiKeys[$apiKeyIdentifier] ?? null;
}

public function setApiKeyPrefix($apiKeyIdentifier, $prefix)
Expand All @@ -85,7 +85,7 @@ class Configuration

public function getApiKeyPrefix($apiKeyIdentifier)
{
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
return $this->apiKeyPrefixes[$apiKeyIdentifier] ?? null;
}

public function setAccessToken($accessToken)
Expand Down Expand Up @@ -220,19 +220,14 @@ class Configuration

public function getApiKeyWithPrefix($apiKeyIdentifier)
{
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
$apiKey = $this->getApiKey($apiKeyIdentifier);

if ($apiKey === null) {
return null;
}

if ($prefix === null) {
$keyWithPrefix = $apiKey;
} else {
$keyWithPrefix = $prefix . ' ' . $apiKey;
}
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);

return $keyWithPrefix;
return $prefix === null ? $apiKey : $prefix . ' ' . $apiKey;
}
}
2 changes: 1 addition & 1 deletion swagger-config/marketing/php/templates/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use {{invokerPackage}}\ObjectSerializer;
protected $config;
protected $headerSelector;

public function __construct(Configuration $config = null)
public function __construct(?Configuration $config = null)
{
$this->client = new Client([
'defaults' => [
Expand Down
2 changes: 1 addition & 1 deletion swagger-config/transactional/php/templates/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use {{invokerPackage}}\ObjectSerializer;
{
protected $config;

public function __construct(Configuration $config = null)
public function __construct(?Configuration $config = null)
{
$this->config = $config ?: new Configuration();
}
Expand Down