AjaxMiddleware::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace app\Middlewares;
4
5
use app\Middlewares\MiddlewareIntrerface\MiddlewaresInterface;
6
7
class AjaxMiddleware implements MiddlewaresInterface
8
{
9
    /**
10
     * Check if the request is by Ajax.
11
     *
12
     * @property object $url
13
     */
14
    public function handle()
15
    {
16
        if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
17
            return $this->url->redirectTo('404');
0 ignored issues
show
Bug introduced by
The property url 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...
18
        }
19
        return true;
20
    }
21
}
22