Completed
Push — develop ( 9a08bc...c3dea4 )
by Sean
02:58
created

RouteParams   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 4 1
A setKey() 0 6 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
use Illuminate\Contracts\Http\Parser as ParserContract;
16
17
class RouteParams implements ParserContract
18
{
19
20
    /**
21
     * The route param key
22
     *
23
     * @var string
24
     */
25
    protected $key = 'token';
26
27
    /**
28
     * Try to get the token from the route parameters
29
     *
30
     * @param  \Illuminate\Http\Request
31
     *
32
     * @return null|string
33
     */
34
    public function parse(Request $request)
35
    {
36
        return $request->route()->parameter($this->key);
37
    }
38
39
    /**
40
     * Set the query string key
41
     *
42
     * @param  string  $key
43
     *
44
     * @return RouteParams
45
     */
46
    public function setKey($key)
47
    {
48
        $this->key = $key;
49
50
        return $this;
51
    }
52
}
53