LumenRouteParams.php 891 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /*
  3. * This file is part of jwt-auth.
  4. *
  5. * (c) 2014-2021 Sean Tymon <tymon148@gmail.com>
  6. * (c) 2021 PHP Open Source Saver
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace PHPOpenSourceSaver\JWTAuth\Http\Parser;
  12. use Illuminate\Http\Request;
  13. use Illuminate\Support\Arr;
  14. class LumenRouteParams extends RouteParams
  15. {
  16. /**
  17. * Try to get the token from the route parameters.
  18. *
  19. * @return string|null
  20. */
  21. public function parse(Request $request)
  22. {
  23. // WARNING: Only use this parser if you know what you're doing!
  24. // It will only work with poorly-specified aspects of certain Lumen releases.
  25. // Route is the expected kind of array, and has a parameter with the key we want.
  26. return Arr::get($request->route(), '2.'.$this->key);
  27. }
  28. }