Completed
Push — master ( 17bcf1...528abf )
by Dmitry
10:53
created

MiddlewareBuilderTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A pipe() 0 6 1
1
<?php
2
3
4
namespace hiapi\endpoints\Module\Middleware;
5
6
use Closure;
7
8
/**
9
 * Trait MiddlewareBuilderTrait
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
trait MiddlewareBuilderTrait
14
{
15
    /**
16
     * @psalm-var list<string|Closure>
17
     */
18
    protected $pipe = [];
19
20
    public function pipe(...$middlewares)
21
    {
22
        $this->middlewares = $middlewares;
0 ignored issues
show
Bug introduced by
The property middlewares 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
24
        return $this;
25
    }
26
}
27