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

QueueDecorator::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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