Skip to content

Commit

Permalink
Removes unnecessary else after return (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmanno authored and bshaffer committed Apr 19, 2018
1 parent 8f7c961 commit 42e2656
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/CredentialsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ public static function makeCredentials($scope, array $jsonKey)

if ($jsonKey['type'] == 'service_account') {
return new ServiceAccountCredentials($scope, $jsonKey);
} elseif ($jsonKey['type'] == 'authorized_user') {
}

if ($jsonKey['type'] == 'authorized_user') {
return new UserRefreshCredentials($scope, $jsonKey);
} else {
throw new \InvalidArgumentException('invalid value in the type field');
}

throw new \InvalidArgumentException('invalid value in the type field');
}

/**
Expand Down
36 changes: 23 additions & 13 deletions src/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ public function getCacheKey()
{
if (is_string($this->scope)) {
return $this->scope;
} elseif (is_array($this->scope)) {
}

if (is_array($this->scope)) {
return implode(':', $this->scope);
}

Expand All @@ -543,14 +545,14 @@ public function parseTokenResponse(ResponseInterface $resp)
parse_str($body, $res);

return $res;
} else {
// Assume it's JSON; if it's not throw an exception
if (null === $res = json_decode($body, true)) {
throw new \Exception('Invalid JSON response');
}
}

return $res;
// Assume it's JSON; if it's not throw an exception
if (null === $res = json_decode($body, true)) {
throw new \Exception('Invalid JSON response');
}

return $res;
}

/**
Expand Down Expand Up @@ -804,15 +806,21 @@ public function getGrantType()
// state.
if (!is_null($this->code)) {
return 'authorization_code';
} elseif (!is_null($this->refreshToken)) {
}

if (!is_null($this->refreshToken)) {
return 'refresh_token';
} elseif (!is_null($this->username) && !is_null($this->password)) {
}

if (!is_null($this->username) && !is_null($this->password)) {
return 'password';
} elseif (!is_null($this->issuer) && !is_null($this->signingKey)) {
}

if (!is_null($this->issuer) && !is_null($this->signingKey)) {
return self::JWT_URN;
} else {
return null;
}

return null;
}

/**
Expand Down Expand Up @@ -1119,7 +1127,9 @@ public function getExpiresAt()
{
if (!is_null($this->expiresAt)) {
return $this->expiresAt;
} elseif (!is_null($this->issuedAt) && !is_null($this->expiresIn)) {
}

if (!is_null($this->issuedAt) && !is_null($this->expiresIn)) {
return $this->issuedAt + $this->expiresIn;
}

Expand Down

0 comments on commit 42e2656

Please sign in to comment.