Skip to content

Commit 7489ce0

Browse files
committed
CS fixes and added docblocs
1 parent 03ce323 commit 7489ce0

13 files changed

+169
-43
lines changed

src/Authorizer.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ class Authorizer
4848

4949
/**
5050
* The redirect uri generator.
51+
*
52+
* @var bool|null
5153
*/
5254
protected $redirectUriGenerator = null;
5355

5456
/**
5557
* Create a new Authorizer instance.
5658
*
57-
* @param Issuer $issuer
58-
* @param Checker $checker
59+
* @param \League\OAuth2\Server\AuthorizationServer $issuer
60+
* @param \League\OAuth2\Server\ResourceServer $checker
5961
*/
6062
public function __construct(Issuer $issuer, Checker $checker)
6163
{
@@ -65,6 +67,8 @@ public function __construct(Issuer $issuer, Checker $checker)
6567
}
6668

6769
/**
70+
* Get the issuer.
71+
*
6872
* @return \League\OAuth2\Server\AuthorizationServer
6973
*/
7074
public function getIssuer()
@@ -73,6 +77,8 @@ public function getIssuer()
7377
}
7478

7579
/**
80+
* Get the checker.
81+
*
7682
* @return \League\OAuth2\Server\ResourceServer
7783
*/
7884
public function getChecker()
@@ -249,7 +255,7 @@ public function getResourceOwnerType()
249255
}
250256

251257
/**
252-
* get the client id of the current request.
258+
* Get the client id of the current request.
253259
*
254260
* @return string
255261
*/

src/Middleware/CheckAuthCodeRequestMiddleware.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,23 @@ class CheckAuthCodeRequestMiddleware
2929
protected $authorizer;
3030

3131
/**
32-
* @param Authorizer $authorizer
32+
* Create a new check auth code request middleware instance.
33+
*
34+
* @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
3335
*/
3436
public function __construct(Authorizer $authorizer)
3537
{
3638
$this->authorizer = $authorizer;
3739
}
3840

41+
/**
42+
* Handle an incoming request.
43+
*
44+
* @param \Illuminate\Http\Request $request
45+
* @param \Closure $next
46+
*
47+
* @return mixed
48+
*/
3949
public function handle($request, Closure $next)
4050
{
4151
$this->authorizer->checkAuthCodeRequest();

src/Middleware/OAuthExceptionHandlerMiddleware.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@
2222
*/
2323
class OAuthExceptionHandlerMiddleware
2424
{
25+
/**
26+
* Handle an incoming request.
27+
*
28+
* @param \Illuminate\Http\Request $request
29+
* @param \Closure $next
30+
*
31+
* @return mixed
32+
*/
2533
public function handle($request, Closure $next)
2634
{
2735
try {
2836
return $next($request);
2937
} catch (OAuthException $e) {
30-
return new JsonResponse([
31-
'error' => $e->errorType,
32-
'error_description' => $e->getMessage(),
33-
],
34-
$e->httpStatusCode,
35-
$e->getHttpHeaders()
36-
);
38+
$data = [
39+
'error' => $e->errorType,
40+
'error_description' => $e->getMessage(),
41+
];
42+
43+
return new JsonResponse($data, $e->httpStatusCode, $e->getHttpHeaders());
3744
}
3845
}
3946
}

src/Middleware/OAuthMiddleware.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class OAuthMiddleware
3737
protected $httpHeadersOnly = false;
3838

3939
/**
40-
* @param Authorizer $authorizer
40+
* Create a new oauth middleware instance.
41+
*
42+
* @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
4143
* @param bool $httpHeadersOnly
4244
*/
4345
public function __construct(Authorizer $authorizer, $httpHeadersOnly = false)
@@ -46,6 +48,17 @@ public function __construct(Authorizer $authorizer, $httpHeadersOnly = false)
4648
$this->httpHeadersOnly = $httpHeadersOnly;
4749
}
4850

51+
/**
52+
* Handle an incoming request.
53+
*
54+
* @param \Illuminate\Http\Request $request
55+
* @param \Closure $next
56+
* @param string|null $scopesString
57+
*
58+
* @throws \League\OAuth2\Server\Exception\InvalidScopeException
59+
*
60+
* @return mixed
61+
*/
4962
public function handle($request, Closure $next, $scopesString = null)
5063
{
5164
$scopes = [];
@@ -65,7 +78,7 @@ public function handle($request, Closure $next, $scopesString = null)
6578
*
6679
* @param $scopes
6780
*
68-
* @throws InvalidScopeException
81+
* @throws \League\OAuth2\Server\Exception\InvalidScopeException
6982
*/
7083
public function validateScopes($scopes)
7184
{

src/Middleware/OAuthOwnerMiddleware.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,26 @@ class OAuthOwnerMiddleware
3030
protected $authorizer;
3131

3232
/**
33-
* @param Authorizer $authorizer
33+
* Create a new oauth owner middleware instance.
34+
*
35+
* @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
3436
*/
3537
public function __construct(Authorizer $authorizer)
3638
{
3739
$this->authorizer = $authorizer;
3840
}
3941

42+
/**
43+
* Handle an incoming request.
44+
*
45+
* @param \Illuminate\Http\Request $request
46+
* @param \Closure $next
47+
* @param string|null $ownerTypesString
48+
*
49+
* @throws \League\OAuth2\Server\Exception\AccessDeniedException
50+
*
51+
* @return mixed
52+
*/
4053
public function handle($request, Closure $next, $ownerTypesString = null)
4154
{
4255
$ownerTypes = [];

src/Storage/AbstractFluentAdapter.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,67 @@
2222
abstract class AbstractFluentAdapter extends AbstractStorage
2323
{
2424
/**
25+
* The connection resolver instance.
26+
*
2527
* @var \Illuminate\Database\ConnectionResolverInterface
2628
*/
2729
protected $resolver;
2830

2931
/**
32+
* The connection name.
33+
*
3034
* @var string
3135
*/
3236
protected $connectionName;
3337

38+
/**
39+
* Create a new abstract fluent adapter instance.
40+
*
41+
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
42+
*/
3443
public function __construct(Resolver $resolver)
3544
{
3645
$this->resolver = $resolver;
3746
$this->connectionName = null;
3847
}
3948

49+
/**
50+
* Set the resolver.
51+
*
52+
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
53+
*/
4054
public function setResolver(Resolver $resolver)
4155
{
4256
$this->resolver = $resolver;
4357
}
4458

59+
/**
60+
* Get the resolver.
61+
*
62+
* @return \Illuminate\Database\ConnectionResolverInterface
63+
*/
4564
public function getResolver()
4665
{
4766
return $this->resolver;
4867
}
4968

69+
/**
70+
* Set the connection name.
71+
*
72+
* @param string $connectionName
73+
*
74+
* @return void
75+
*/
5076
public function setConnectionName($connectionName)
5177
{
5278
$this->connectionName = $connectionName;
5379
}
5480

81+
/**
82+
* Get the connection.
83+
*
84+
* @return \Illuminate\Database\ConnectionInterface
85+
*/
5586
protected function getConnection()
5687
{
5788
return $this->resolver->connection($this->connectionName);

src/Storage/FluentAccessToken.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FluentAccessToken extends AbstractFluentAdapter implements AccessTokenInte
2626
/**
2727
* Get an instance of Entities\AccessToken.
2828
*
29-
* @param string $token The access token
29+
* @param string $token The access token
3030
*
3131
* @return null|AbstractTokenEntity
3232
*/
@@ -45,7 +45,8 @@ public function get($token)
4545
->setExpireTime((int) $result->expire_time);
4646
}
4747

48-
/*public function getByRefreshToken(RefreshTokenEntity $refreshToken)
48+
/*
49+
public function getByRefreshToken(RefreshTokenEntity $refreshToken)
4950
{
5051
$result = $this->getConnection()->table('oauth_access_tokens')
5152
->select('oauth_access_tokens.*')
@@ -60,7 +61,8 @@ public function get($token)
6061
return (new AccessTokenEntity($this->getServer()))
6162
->setId($result->id)
6263
->setExpireTime((int)$result->expire_time);
63-
}*/
64+
}
65+
*/
6466

6567
/**
6668
* Get the scopes for an access token.
@@ -92,9 +94,9 @@ public function getScopes(AccessTokenEntity $token)
9294
/**
9395
* Creates a new access token.
9496
*
95-
* @param string $token The access token
96-
* @param int $expireTime The expire time expressed as a unix timestamp
97-
* @param string|int $sessionId The session ID
97+
* @param string $token The access token
98+
* @param int $expireTime The expire time expressed as a unix timestamp
99+
* @param string|int $sessionId The session ID
98100
*
99101
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
100102
*/

src/Storage/FluentAuthCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function get($code)
5050
/**
5151
* Get the scopes for an access token.
5252
*
53-
* @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code
53+
* @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The auth code
5454
*
5555
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
5656
*/

src/Storage/FluentClient.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525
class FluentClient extends AbstractFluentAdapter implements ClientInterface
2626
{
2727
/**
28+
* Limit clients to grants.
29+
*
2830
* @var bool
2931
*/
3032
protected $limitClientsToGrants = false;
3133

3234
/**
33-
* @param Resolver $connection
35+
* Create a new fluent client instance.
36+
*
37+
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
3438
* @param bool $limitClientsToGrants
3539
*/
3640
public function __construct(Resolver $resolver, $limitClientsToGrants = false)
@@ -40,6 +44,8 @@ public function __construct(Resolver $resolver, $limitClientsToGrants = false)
4044
}
4145

4246
/**
47+
* Check if clients are limited to grants.
48+
*
4349
* @return bool
4450
*/
4551
public function areClientsLimitedToGrants()
@@ -48,14 +54,18 @@ public function areClientsLimitedToGrants()
4854
}
4955

5056
/**
51-
* @param bool $limit whether or not to limit clients to grants
57+
* Whether or not to limit clients to grants.
58+
*
59+
* @param bool $limit
5260
*/
5361
public function limitClientsToGrants($limit = false)
5462
{
5563
$this->limitClientsToGrants = $limit;
5664
}
5765

5866
/**
67+
* Get the client.
68+
*
5969
* @param string $clientId
6070
* @param string $clientSecret
6171
* @param string $redirectUri
@@ -139,6 +149,8 @@ public function getBySession(SessionEntity $session)
139149
}
140150

141151
/**
152+
* Create a new client.
153+
*
142154
* @param string $name The client's unique name
143155
* @param string $id The client's unique id
144156
* @param string $secret The clients' unique secret
@@ -157,6 +169,8 @@ public function create($name, $id, $secret)
157169
}
158170

159171
/**
172+
* Hydrate the entity.
173+
*
160174
* @param $result
161175
*
162176
* @return \League\OAuth2\Server\Entity\ClientEntity

src/Storage/FluentRefreshToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FluentRefreshToken extends AbstractFluentAdapter implements RefreshTokenIn
2525
/**
2626
* Return a new instance of \League\OAuth2\Server\Entity\RefreshTokenEntity.
2727
*
28-
* @param string $token
28+
* @param string $token
2929
*
3030
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
3131
*/

0 commit comments

Comments
 (0)