Completed
Push — develop ( 7b8c01...54328c )
by Sean
02:43
created

LumenRouteParams::parse()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
ccs 4
cts 5
cp 0.8
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
crap 3.072
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 2
    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 2
        $route = $request->route();
30
31 2
        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 2
        return $route[2][$this->key];
37
    }
38
}
39