HandlerStack   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 58
ccs 14
cts 14
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 1
A current() 0 3 1
A reset() 0 3 1
A flush() 0 5 1
A empty() 0 3 1
A next() 0 3 1
1
<?php
2
declare(strict_types=1);
3
namespace Modulate\Artisan\Interceptor;
4
5
use Illuminate\Foundation\Exceptions\Handler;
6
use Modulate\Artisan\Interceptor\Contracts\ArtisanHandler;
7
use Modulate\Artisan\Interceptor\Contracts\Handler as HandlerContract;
8
use Modulate\Artisan\Interceptor\Contracts\HandlerStack as HandlerStackContract;
9
10
class HandlerStack implements HandlerStackContract
11
{
12
    /**
13
     * Stores the handlers in the stack
14
     *
15
     * @var HandlerContract[]|ArtisanHandler[]
16
     */
17
    protected array $stack = [];
18
19
    /**
20
     * @inheritDoc
21
     */
22 8
    public function push(HandlerContract|ArtisanHandler $handler): HandlerStackContract
23
    {
24 8
        $this->stack[] = $handler;
25 8
        return $this;
26
    }
27
28
    /**
29
     * @inheritDoc
30
     */
31 11
    public function empty(): bool
32
    {
33 11
        return empty($this->stack);
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39 6
    public function current(): HandlerContract|ArtisanHandler|bool
40
    {
41 6
        return current($this->stack);
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47 6
    public function next(): HandlerContract|ArtisanHandler|bool
48
    {
49 6
        return next($this->stack);
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55 8
    public function reset(): void
56
    {
57 8
        reset($this->stack);
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63 1
    public function flush(): HandlerStackContract
64
    {
65 1
        $this->stack = [];
66
67 1
        return $this;
68
    }
69
70
}
71