Passed
Branch 1.0 (690a53)
by Vladimir
07:08
created

SyncQueue::later()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Queue;
6
7
use FondBot\Drivers\Driver;
8
use FondBot\Contracts\Queue;
9
use FondBot\Drivers\Command;
10
11
class SyncQueue implements Queue
12
{
13
    /**
14
     * Push command onto the queue.
15
     *
16
     * @param Driver  $driver
17
     * @param Command $command
18
     */
19 2
    public function push(Driver $driver, Command $command): void
20
    {
21 2
        $driver->handle($command);
22 2
    }
23
24
    /**
25
     * Push command onto the queue with a delay.
26
     *
27
     * @param Driver  $driver
28
     * @param Command $command
29
     * @param int     $delay
30
     *
31
     * @return mixed|void
32
     */
33 1
    public function later(Driver $driver, Command $command, int $delay): void
34
    {
35 1
        if ($delay > 0) {
36 1
            sleep($delay);
37
        }
38
39 1
        $this->push($driver, $command);
40 1
    }
41
}
42