Restricter::isRestrictionEnabled()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Tequilarapido\RestrictAccess\Restricter;
4
5
use Illuminate\Http\Request;
6
7
abstract class Restricter
8
{
9
    /**
10
     * @param Request $request
11
     */
12
    public function __construct(Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
13
    {
14
        $this->request = $request;
0 ignored issues
show
Bug introduced by
The property request 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...
15
    }
16
17
    /**
18
     * Do we need to restrict access ?
19
     */
20
    abstract public function isRestrictionEnabled();
21
22
    /**
23
     * Protection method.
24
     *
25
     * @return mixed
26
     */
27
    abstract public function restrict();
28
}
29