Skip to content
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"test": "phpunit"
},
"require": {
"php": "^5.6|^7.0|^8.0"
},
"php": "^7.1|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.90.0",
"phpunit/phpunit": "^9.6"
Expand Down
71 changes: 30 additions & 41 deletions src/SumUp/Application/ApplicationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function __construct(array $config = [])
*
* @return string
*/
public function getAppId()
public function getAppId(): string
{
return $this->appId;
}
Expand All @@ -182,7 +182,7 @@ public function getAppId()
*
* @return string
*/
public function getAppSecret()
public function getAppSecret(): string
{
return $this->appSecret;
}
Expand All @@ -192,7 +192,7 @@ public function getAppSecret()
*
* @return array
*/
public function getScopes()
public function getScopes(): array
{
return $this->scopes;
}
Expand All @@ -202,7 +202,7 @@ public function getScopes()
*
* @return string
*/
public function getFormattedScopes()
public function getFormattedScopes(): string
{
return implode(' ', $this->scopes);
}
Expand All @@ -212,17 +212,17 @@ public function getFormattedScopes()
*
* @return string
*/
public function getBaseURL()
public function getBaseURL(): string
{
return $this->baseURL;
}

/**
* Returns authorization code.
*
* @return null|string
* @return string
*/
public function getCode()
public function getCode(): string
{
return $this->code;
}
Expand All @@ -232,27 +232,27 @@ public function getCode()
*
* @return string;
*/
public function getGrantType()
public function getGrantType(): string
{
return $this->grantType;
}

/**
* Returns merchant's username.
*
* @return null|string
* @return string
*/
public function getUsername()
public function getUsername(): string
{
return $this->username;
}

/**
* Returns merchant's password.
*
* @return null|string
* @return string
*/
public function getPassword()
public function getPassword(): string
{
return $this->password;
}
Expand All @@ -262,7 +262,7 @@ public function getPassword()
*
* @return null|string
*/
public function getAccessToken()
public function getAccessToken(): ?string
{
return $this->accessToken;
}
Expand All @@ -272,7 +272,7 @@ public function getAccessToken()
*
* @return null|string
*/
public function getRefreshToken()
public function getRefreshToken(): ?string
{
return $this->refreshToken;
}
Expand All @@ -282,7 +282,7 @@ public function getRefreshToken()
*
* @return bool
*/
public function getForceGuzzle()
public function getForceGuzzle(): bool
{
return $this->forceGuzzle;
}
Expand All @@ -292,7 +292,7 @@ public function getForceGuzzle()
*
* @return array
*/
public function getCustomHeaders()
public function getCustomHeaders(): array
{
return $this->customHeaders;
}
Expand All @@ -302,7 +302,7 @@ public function getCustomHeaders()
*
* @return string|null
*/
public function getCABundlePath()
public function getCABundlePath(): ?string
{
if (!empty($this->caBundlePath)) {
return $this->caBundlePath;
Expand All @@ -316,19 +316,19 @@ public function getCABundlePath()
*
* @return string|null
*/
public function getApiKey()
public function getApiKey(): ?string
{
return $this->apiKey;
}

/**
* Set application ID.
*
* @param string $appId
* @param ?string $appId
*
* @throws SumUpConfigurationException
*/
protected function setAppId($appId)
protected function setAppId(?string $appId): void
{
if (empty($appId) && empty($this->apiKey)) {
throw new SumUpConfigurationException('Missing mandatory parameter app_id or api_key');
Expand All @@ -343,7 +343,7 @@ protected function setAppId($appId)
*
* @throws SumUpConfigurationException
*/
protected function setAppSecret($appSecret)
protected function setAppSecret(?string $appSecret): void
{
if (empty($appSecret) && empty($this->apiKey)) {
throw new SumUpConfigurationException('Missing mandatory parameter app_secret or api_key');
Expand All @@ -354,11 +354,11 @@ protected function setAppSecret($appSecret)
/**
* Set the authorization grant type.
*
* @param array $grantType
* @param string $grantType
*
* @throws SumUpConfigurationException
*/
protected function setGrantType($grantType)
protected function setGrantType(string $grantType): void
{
if (!in_array($grantType, $this::GRANT_TYPES)) {
throw new SumUpConfigurationException('Invalid parameter for "grant_type". Allowed values are: ' . implode(' | ', $this::GRANT_TYPES) . '.');
Expand All @@ -371,24 +371,18 @@ protected function setGrantType($grantType)
*
* @param array $scopes
*/
protected function setScopes(array $scopes = [])
protected function setScopes(array $scopes = []): void
{
$this->scopes = array_unique(array_merge($this::DEFAULT_SCOPES, $scopes), SORT_REGULAR);
;
}

/**
* Set the flag whether to use GuzzleHttp.
*
* @param bool $forceGuzzle
*
* @throws SumUpConfigurationException
*/
protected function setForceGuzzle($forceGuzzle)
protected function setForceGuzzle(bool $forceGuzzle): void
{
if (!is_bool($forceGuzzle)) {
throw new SumUpConfigurationException('Invalid value for boolean parameter use_guzzlehttp_over_curl.');
}
$this->forceGuzzle = $forceGuzzle;
}

Expand All @@ -397,12 +391,11 @@ protected function setForceGuzzle($forceGuzzle)
*
* @param array $customHeaders
*/
public function setCustomHeaders($customHeaders)
public function setCustomHeaders(array $customHeaders): void
{
$headers = is_array($customHeaders) ? $customHeaders : [];
$headers[self::USER_AGENT_HEADER] = SdkInfo::getUserAgent();
$customHeaders[self::USER_AGENT_HEADER] = SdkInfo::getUserAgent();

$this->customHeaders = $headers;
$this->customHeaders = $customHeaders;
}

/**
Expand All @@ -412,17 +405,13 @@ public function setCustomHeaders($customHeaders)
*
* @throws SumUpConfigurationException
*/
protected function setCABundlePath($caBundlePath)
protected function setCABundlePath(?string $caBundlePath): void
{
if ($caBundlePath === null || $caBundlePath === '') {
$this->caBundlePath = null;
return;
}

if (!is_string($caBundlePath)) {
throw new SumUpConfigurationException('Invalid value for "ca_bundle_path". Expected string path or null.');
}

if (!is_readable($caBundlePath)) {
throw new SumUpConfigurationException(sprintf('The provided ca_bundle_path "%s" is not readable.', $caBundlePath));
}
Expand All @@ -435,7 +424,7 @@ protected function setCABundlePath($caBundlePath)
*
* @return string|null
*/
private function getDefaultCABundlePath()
private function getDefaultCABundlePath(): ?string
{
$path = realpath(__DIR__ . '/../../../resources/ca-bundle.crt');
if ($path && is_readable($path)) {
Expand Down
34 changes: 17 additions & 17 deletions src/SumUp/Application/ApplicationConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,96 +14,96 @@ interface ApplicationConfigurationInterface
*
* @return string
*/
public function getAppId();
public function getAppId(): string;

/**
* Returns application's secret.
*
* @return string
*/
public function getAppSecret();
public function getAppSecret(): string;

/**
* Returns the scopes formatted as they should appear in the request.
*
* @return string
* @return array
*/
public function getScopes();
public function getScopes(): array;

/**
* Returns the base URL of the SumUp API.
*
* @return string
*/
public function getBaseURL();
public function getBaseURL(): string;

/**
* Returns authorization code.
*
* @return string
*/
public function getCode();
public function getCode(): string;

/**
* Returns grant type.
*
* @return string
*/
public function getGrantType();
public function getGrantType(): string;

/**
* Returns merchant's username;
*
* @return string
*/
public function getUsername();
public function getUsername(): string;

/**
* Returns merchant's passowrd;
* Returns merchant's password;
*
* @return string
*/
public function getPassword();
public function getPassword(): string;

/**
* Returns access token.
*
* @return string
* @return string|null
*/
public function getAccessToken();
public function getAccessToken(): ?string;

/**
* Returns refresh token.
*
* @return string
*/
public function getRefreshToken();
public function getRefreshToken(): ?string;

/**
* Returns a flag whether to use GuzzleHttp over cURL if both are present.
*
* @return bool
*/
public function getForceGuzzle();
public function getForceGuzzle(): bool;

/**
* Returns associative array with custom headers.
*
* @return array
*/
public function getCustomHeaders();
public function getCustomHeaders(): array;

/**
* Returns the path to the CA bundle used for HTTPS verification.
*
* @return string|null
*/
public function getCABundlePath();
public function getCABundlePath(): ?string;

/**
* Returns the API key if set.
*
* @return string|null
*/
public function getApiKey();
public function getApiKey(): ?string;
}
Loading