Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from samsonasik/update-to-latest-php81-syntax
Browse files Browse the repository at this point in the history
Update to latest PHP 8.1 syntax
  • Loading branch information
gsteel authored Nov 22, 2024
2 parents 7b438d6 + 3d3398a commit a27e09a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
25 changes: 10 additions & 15 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,16 @@ public function getRequestSchemeQueryStringClient(array $params, $url)
*/
protected function assessRequestAttempt(?Response $response = null)
{
switch ($this->preferredRequestScheme) {
case OAuth::REQUEST_SCHEME_HEADER:
$this->preferredRequestScheme = OAuth::REQUEST_SCHEME_POSTBODY;
break;
case OAuth::REQUEST_SCHEME_POSTBODY:
$this->preferredRequestScheme = OAuth::REQUEST_SCHEME_QUERYSTRING;
break;
default:
throw new Exception\RuntimeException(
'Could not retrieve a valid Token response from Token URL:'
. ($response !== null
? PHP_EOL . $response->getBody()
: ' No body - check for headers')
);
}
$this->preferredRequestScheme = match ($this->preferredRequestScheme) {
OAuth::REQUEST_SCHEME_HEADER => OAuth::REQUEST_SCHEME_POSTBODY,
OAuth::REQUEST_SCHEME_POSTBODY => OAuth::REQUEST_SCHEME_QUERYSTRING,
default => throw new Exception\RuntimeException(
'Could not retrieve a valid Token response from Token URL:'
. ($response !== null
? PHP_EOL . $response->getBody()
: ' No body - check for headers')
),
};
}

/**
Expand Down
18 changes: 8 additions & 10 deletions src/Signature/AbstractSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ abstract class AbstractSignature implements SignatureInterface
*/
protected $key;

/**
* Consumer secret
*
* @var string
*/
protected $consumerSecret;

/**
* Token secret
*
Expand All @@ -51,9 +44,14 @@ abstract class AbstractSignature implements SignatureInterface
* @param null|string $hashAlgo
* @return void
*/
public function __construct($consumerSecret, $tokenSecret = null, $hashAlgo = null)
{
$this->consumerSecret = $consumerSecret;
public function __construct(
/**
* Consumer secret
*/
protected $consumerSecret,
$tokenSecret = null,
$hashAlgo = null
) {
if (isset($tokenSecret)) {
$this->tokenSecret = $tokenSecret;
}
Expand Down
9 changes: 2 additions & 7 deletions src/Token/AbstractToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ public function setParams(array $params)
*/
public function getParam($key)
{
if (isset($this->params[$key])) {
return $this->params[$key];
}
return null;
return $this->params[$key] ?? null;
}

/**
Expand Down Expand Up @@ -213,10 +210,8 @@ public function toString()
/**
* Convert Token to a string, specifically a raw encoded query string.
* Aliases to self::toString()
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->toString();
}
Expand Down

0 comments on commit a27e09a

Please sign in to comment.