Completed
Pull Request — master (#42)
by claudio
05:31
created

GetUserAndRefresh   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 1
cbo 3
dl 0
loc 19
ccs 6
cts 8
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 14 5
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Claudio Cardinale <[email protected]>
5
 * Date: 24/12/15
6
 * Time: 22.53
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 */
19
20
namespace plunner\Http\Middleware;
21
22
23
class GetUserAndRefresh extends \Tymon\JWTAuth\Middleware\GetUserAndRefresh
24
{
25 86
    public function handle($request, \Closure $next, $custom = '')
26
    {
27 86
        $remember = false;
28 86
        if($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) &&
29 86
                $remember == 'true'){
30
            $this->app['tymon.jwt.payload.factory']->setTTL(43200);
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
            //config(['jwt.ttl' =>'43200']); //30 days
32
        }
33
34
        //this to add the remember me mode field in the new token, but we have the custom check that is an useless
35
        //overhead
36 86
        $custom = $custom.';remember-'.$remember=='true'?'true':'false';
37 86
        return parent::handle($request, $next, $custom);
38
    }
39
40
41
}