Completed
Push — master ( ed97c6...a00967 )
by Vladimir
06:23
created

SyncAdapter::next()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
     * Pull next job from the queue.
17
     *
18
     * @return Job
19
     */
20 1
    public function next(): ?Job
21
    {
22 1
        return null;
23
    }
24
25
    /**
26
     * Push command onto the queue.
27
     *
28
     * @param Channel $channel
29
     * @param Driver  $driver
30
     * @param Command $command
31
     */
32 2
    public function push(Channel $channel, Driver $driver, Command $command): void
33
    {
34 2
        $driver->handle($command);
35 2
    }
36
37
    /**
38
     * Push command onto the queue with a delay.
39
     *
40
     * @param Channel $channel
41
     * @param Driver  $driver
42
     * @param Command $command
43
     * @param int     $delay
44
     *
45
     * @return mixed|void
46
     */
47 1
    public function later(Channel $channel, Driver $driver, Command $command, int $delay): void
48
    {
49 1
        if ($delay > 0) {
50 1
            sleep($delay);
51
        }
52
53 1
        $this->push($channel, $driver, $command);
54 1
    }
55
}
56