Skip to content

Commit bc56dad

Browse files
authored
Merge pull request #372 from earthiverse/feature/typing
Make Configuration parameter nullable
2 parents 2002d00 + d3b3fa9 commit bc56dad

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

swagger-config/marketing/php/templates/Configuration.mustache

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class Configuration
4141

4242
public function setConfig($config = array())
4343
{
44-
$apiKey = isset($config['apiKey']) ? $config['apiKey'] : '';
45-
$accessToken = isset($config['accessToken']) ? $config['accessToken'] : '';
46-
$server = isset($config['server']) ? $config['server'] : 'invalid-server';
44+
$apiKey = $config['apiKey'] ?? '';
45+
$accessToken = $config['accessToken'] ?? '';
46+
$server = $config['server'] ?? 'invalid-server';
4747
$host = str_replace('server', $server, $this->getHost());
4848
4949
// Basic Authentication
@@ -74,7 +74,7 @@ class Configuration
7474

7575
public function getApiKey($apiKeyIdentifier)
7676
{
77-
return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null;
77+
return $this->apiKeys[$apiKeyIdentifier] ?? null;
7878
}
7979

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

8686
public function getApiKeyPrefix($apiKeyIdentifier)
8787
{
88-
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
88+
return $this->apiKeyPrefixes[$apiKeyIdentifier] ?? null;
8989
}
9090

9191
public function setAccessToken($accessToken)
@@ -220,19 +220,14 @@ class Configuration
220220

221221
public function getApiKeyWithPrefix($apiKeyIdentifier)
222222
{
223-
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
224223
$apiKey = $this->getApiKey($apiKeyIdentifier);
225224
226225
if ($apiKey === null) {
227226
return null;
228227
}
229228

230-
if ($prefix === null) {
231-
$keyWithPrefix = $apiKey;
232-
} else {
233-
$keyWithPrefix = $prefix . ' ' . $apiKey;
234-
}
229+
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
235230

236-
return $keyWithPrefix;
231+
return $prefix === null ? $apiKey : $prefix . ' ' . $apiKey;
237232
}
238233
}

swagger-config/marketing/php/templates/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use {{invokerPackage}}\ObjectSerializer;
3737
protected $config;
3838
protected $headerSelector;
3939
40-
public function __construct(Configuration $config = null)
40+
public function __construct(?Configuration $config = null)
4141
{
4242
$this->client = new Client([
4343
'defaults' => [

swagger-config/transactional/php/templates/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use {{invokerPackage}}\ObjectSerializer;
3636
{
3737
protected $config;
3838
39-
public function __construct(Configuration $config = null)
39+
public function __construct(?Configuration $config = null)
4040
{
4141
$this->config = $config ?: new Configuration();
4242
}

0 commit comments

Comments
 (0)