Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 2, 2023
1 parent 8184690 commit ad36c47
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 46 deletions.
26 changes: 15 additions & 11 deletions src/Http/Middleware/CheckCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ public function __construct(ResourceServer $server, TokenRepository $repository)
$this->repository = $repository;
}

/**
* Specify the scopes for the middleware.
*
* @param array|string $scopes
* @return string
*/
public static function using(...$scopes)
{
if (is_array($scopes[0])) {
return static::class.':'.implode(',', $scopes[0]);
} else {
return static::class.':'.implode(',', $scopes);
}
}

/**
* Handle an incoming request.
*
Expand Down Expand Up @@ -69,17 +84,6 @@ public function handle($request, Closure $next, ...$scopes)
return $next($request);
}

/**
* Generate a string representation of the middleware with specified scopes.
*
* @param array|string $scopes
* @return string
*/
public static function using($scopes)
{
return static::class.':'.implode(',', func_get_args());
}

/**
* Validate the scopes and token on the incoming request.
*
Expand Down
26 changes: 15 additions & 11 deletions src/Http/Middleware/CheckForAnyScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@

class CheckForAnyScope
{
/**
* Specify the scopes for the middleware.
*
* @param array|string $scopes
* @return string
*/
public static function using(...$scopes)
{
if (is_array($scopes[0])) {
return static::class.':'.implode(',', $scopes[0]);
} else {
return static::class.':'.implode(',', $scopes);
}
}

/**
* Handle the incoming request.
*
Expand All @@ -31,15 +46,4 @@ public function handle($request, $next, ...$scopes)

throw new MissingScopeException($scopes);
}

/**
* Generate a string representation of the middleware with specified scopes.
*
* @param array|string $scopes
* @return string
*/
public static function using($scopes)
{
return static::class.':'.implode(',', func_get_args());
}
}
26 changes: 15 additions & 11 deletions src/Http/Middleware/CheckScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@

class CheckScopes
{
/**
* Specify the scopes for the middleware.
*
* @param array|string $scopes
* @return string
*/
public static function using(...$scopes)
{
if (is_array($scopes[0])) {
return static::class.':'.implode(',', $scopes[0]);
} else {
return static::class.':'.implode(',', $scopes);
}
}

/**
* Handle the incoming request.
*
Expand All @@ -31,15 +46,4 @@ public function handle($request, $next, ...$scopes)

return $next($request);
}

/**
* Generate a string representation of the middleware with specified scopes.
*
* @param array|string $scopes
* @return string
*/
public static function using($scopes)
{
return static::class.':'.implode(',', func_get_args());
}
}
26 changes: 13 additions & 13 deletions src/Http/Middleware/CreateFreshApiToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public function __construct(ApiTokenCookieFactory $cookieFactory)
$this->cookieFactory = $cookieFactory;
}

/**
* Specify the guard for the middleware.
*
* @param string|null $guard
* @return string
*/
public static function using($guard = null)
{
$guard = is_null($guard) ? '' : ':'.$guard;

return static::class.$guard;
}

/**
* Handle an incoming request.
*
Expand All @@ -58,19 +71,6 @@ public function handle($request, Closure $next, $guard = null)
return $response;
}

/**
* Specify the guard for the middleware.
*
* @param string|null $guard
* @return string
*/
public static function using($guard = null)
{
$args = is_null($guard) ? '' : ':'.$guard;

return static::class.$args;
}

/**
* Determine if the given request should receive a fresh token.
*
Expand Down

0 comments on commit ad36c47

Please sign in to comment.