Completed
Push — master ( 254852...4bc5b9 )
by Mahmoud
02:56
created

MiddlewaresLoaderTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadContainersInternalMiddlewares() 0 14 2
1
<?php
2
3
namespace App\Port\Loader\Loaders;
4
5
use App;
6
use App\Port\Middleware\PortKernel;
7
8
/**
9
 * Class MiddlewaresLoaderTrait.
10
 *
11
 * @author  Mahmoud Zalt <[email protected]>
12
 */
13
trait MiddlewaresLoaderTrait
14
{
15
16
    public function loadContainersInternalMiddlewares()
17
    {
18
        // TODO: might need refactoring to get rid of the functions on the PortKernel
19
20
        // Registering single and grouped middleware's
21
        $portKernel = App::make(PortKernel::class);
22
        $portKernel->registerMiddlewares($this->middleware);
0 ignored issues
show
Bug introduced by
The property middleware 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...
23
        $portKernel->registerMiddlewareGroups($this->middlewareGroups);
0 ignored issues
show
Bug introduced by
The property middlewareGroups does not seem to exist. Did you mean middleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
24
25
        // Registering Route Middleware's
26
        foreach ($this->routeMiddleware as $key => $routeMiddleware) {
0 ignored issues
show
Bug introduced by
The property routeMiddleware does not seem to exist. Did you mean middleware?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
27
            $this->app['router']->middleware($key, $routeMiddleware);
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...
28
        }
29
    }
30
}
31