Completed
Push — master ( 1fad07...9ffd04 )
by Vladimir
08:28
created

SyncAdapter::connect()   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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
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\Adapter;
8
use FondBot\Drivers\Driver;
9
use FondBot\Drivers\Command;
10
use FondBot\Channels\Channel;
11
12
class SyncAdapter extends Adapter
13
{
14
    /**
15
     * Establish connection to the queue.
16
     */
17
    public function connect(): void
18
    {
19
    }
20
21
    /**
22
     * Push command onto the queue.
23
     *
24
     * @param Channel $channel
25
     * @param Driver  $driver
26
     * @param Command $command
27
     */
28 2
    public function push(Channel $channel, Driver $driver, Command $command): void
29
    {
30 2
        $driver->handle($command);
31 2
    }
32
33
    /**
34
     * Push command onto the queue with a delay.
35
     *
36
     * @param Channel $channel
37
     * @param Driver  $driver
38
     * @param Command $command
39
     * @param int     $delay
40
     *
41
     * @return mixed|void
42
     */
43 1
    public function later(Channel $channel, Driver $driver, Command $command, int $delay): void
44
    {
45 1
        if ($delay > 0) {
46 1
            sleep($delay);
47
        }
48
49 1
        $this->push($channel, $driver, $command);
50 1
    }
51
}
52