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

LumenRouteParams   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 23
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 3
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