Passed
Pull Request — master (#140)
by Alexander
05:08 queued 02:34
created

QueueDecorator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 10
c 1
b 0
f 0
dl 0
loc 40
ccs 0
cts 16
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 3 1
A push() 0 4 1
A status() 0 6 1
A getChannelName() 0 3 1
A __construct() 0 4 1
A listen() 0 3 1
A withAdapter() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector;
6
7
use Yiisoft\Yii\Queue\Adapter\AdapterInterface;
8
use Yiisoft\Yii\Queue\Enum\JobStatus;
9
use Yiisoft\Yii\Queue\Message\MessageInterface;
10
use Yiisoft\Yii\Queue\QueueInterface;
11
12
final class QueueDecorator implements QueueInterface
13
{
14
    public function __construct(
15
        private QueueInterface $queue,
16
        private QueueCollector $collector,
17
    ) {
18
    }
19
20
    public function status(string $id): JobStatus
21
    {
22
        $result = $this->queue->status($id);
23
        $this->collector->collectStatus($id);
24
25
        return $result;
26
    }
27
28
    public function push(MessageInterface $message): void
29
    {
30
        $this->queue->push($message);
31
        $this->collector->collectPush($this->queue->getChannelName(), $message);
32
    }
33
34
    public function run(int $max = 0): void
35
    {
36
        $this->queue->run($max);
37
    }
38
39
    public function listen(): void
40
    {
41
        $this->queue->listen();
42
    }
43
44
    public function withAdapter(AdapterInterface $adapter): QueueInterface
45
    {
46
        return $this->queue->withAdapter($adapter);
47
    }
48
49
    public function getChannelName(): string
50
    {
51
        return $this->queue->getChannelName();
52
    }
53
}
54