Completed
Push — master ( b739db...92d607 )
by Abdelrahman
02:42
created

ManagePersistenceController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Controllers\Frontend;
17
18
use Illuminate\Support\Facades\Auth;
19
use Illuminate\Support\Facades\Lang;
20
use Rinvex\Fort\Http\Controllers\AuthorizedController;
21
22
class ManagePersistenceController extends AuthorizedController
23
{
24
    /**
25
     * Show the account sessions.
26
     *
27
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
28
     */
29
    public function showPersistence()
30
    {
31
        return view('rinvex.fort::frontend.profile.persistence');
32
    }
33
34
    /**
35
     * Flush the given session.
36
     *
37
     * @param string $token
0 ignored issues
show
Documentation introduced by
Should the type for parameter $token not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
38
     *
39
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
40
     */
41
    public function processPersistenceFlush($token = null)
42
    {
43
        $status = '';
44
45
        if ($token) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $token of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
46
            app('rinvex.fort.persistence')->delete($token);
47
            $status = Lang::get('rinvex.fort::message.auth.session.flushed');
48
        } elseif (request()->get('confirm')) {
49
            app('rinvex.fort.persistence')->deleteByUser(Auth::guard($this->getGuard())->user()->id);
50
            $status = Lang::get('rinvex.fort::message.auth.session.flushedall');
51
        }
52
53
        return intend([
54
            'back' => true,
55
            'with' => ['rinvex.fort.alert.warning' => $status],
56
        ]);
57
    }
58
}
59