AjaxMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 2
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