Completed
Push — master ( 96e614...1e74ba )
by Vladimir
03:46
created

SyncAdapter::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Queue\Adapters;
6
7
use FondBot\Queue\Job;
8
use FondBot\Queue\Adapter;
9
use FondBot\Drivers\Driver;
10
use FondBot\Drivers\Command;
11
use FondBot\Channels\Channel;
12
13
class SyncAdapter extends Adapter
14
{
15
    /**
16
     * Establish connection to the queue.
17
     */
18 1
    public function connect(): void
19
    {
20 1
    }
21
22
    /**
23
     * Pull next job from the queue.
24
     *
25
     * @return Job
26
     */
27
    public function next(): ?Job
28
    {
29
        return null;
30
    }
31
32
    /**
33
     * Push command onto the queue.
34
     *
35
     * @param Channel $channel
36
     * @param Driver  $driver
37
     * @param Command $command
38
     */
39 2
    public function push(Channel $channel, Driver $driver, Command $command): void
40
    {
41 2
        $driver->handle($command);
42 2
    }
43
44
    /**
45
     * Push command onto the queue with a delay.
46
     *
47
     * @param Channel $channel
48
     * @param Driver  $driver
49
     * @param Command $command
50
     * @param int     $delay
51
     *
52
     * @return mixed|void
53
     */
54 1
    public function later(Channel $channel, Driver $driver, Command $command, int $delay): void
55
    {
56 1
        if ($delay > 0) {
57 1
            sleep($delay);
58
        }
59
60 1
        $this->push($channel, $driver, $command);
61 1
    }
62
}
63