MiddlewareStack   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 6 1
1
<?php
2
3
namespace Schnittstabil\Psr7\MiddlewareStack;
4
5
/**
6
 * Immutable middleware stack.
7
 */
8
class MiddlewareStack implements MiddlewareStackInterface
9
{
10
    use CallableMiddlewareStackTrait;
11
12
    /**
13
     * Create new stack.
14
     *
15
     * @param callable $bottomMiddleware last middleware to be called
16
     */
17
    public function __construct(callable $bottomMiddleware = null)
18
    {
19
        $this->middlewareStack = $bottomMiddleware;
20
    }
21
22
    /**
23
     * Push a middleware onto the top of a new Stack instance.
24
     *
25
     * @param callable $newTopMiddleware the middleware to be pushed onto the top.
26
     *
27
     * @return static the new instance
28
     */
29
    public function add(callable $newTopMiddleware)
30
    {
31
        $clone = clone $this;
32
33
        return $clone->push($newTopMiddleware);
34
    }
35
}
36