Completed
Pull Request — develop (#391)
by
unknown
62:22
created

LumenRouteParams::parse()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4286
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of jwt-auth
5
 *
6
 * (c) Sean Tymon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tymon\JWTAuth\Http;
13
14
use Illuminate\Http\Request;
15
16
class LumenRouteParams extends RouteParams
17
{
18
    /**
19
     * Try to get the token from the route parameters
20
     *
21
     * @param  \Illuminate\Http\Request
22
     *
23
     * @return null|string
24
     */
25
    public function parse(Request $request)
26
    {
27
        // WARNING: Only use this parser if you know what you're doing!
28
        // It will only work with poorly-specified aspects of certain Lumen releases.
29
        $route = $request->route();
30
31
        if (! is_array($route) || ! array_has($route, '2.'.$this->key)) {
32
            // Route is not the expected kind of array, or does not have a parameter
33
            // with the key we want.
34
            return null;
35
        }
36
        return $route[2][$this->key];
37
    }
38
}
39