Passed
Push — master ( 92d93f...feff91 )
by Albert
04:27 queued 02:14
created

InteractsWithSwooleQueue::isSwooleQueuePacket()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SwooleTW\Http\Concerns;
4
5
use Swoole\Table;
6
use SwooleTW\Http\Table\SwooleTable;
7
8
trait InteractsWithSwooleQueue
9
{
10
    /**
11
     * Indicates if a packet is swoole's queue job.
12
     *
13
     * @param mixed
14
     */
15
    protected function isSwooleQueuePacket($packet)
16
    {
17
        if (! is_string($packet)) {
18
            return false;
19
        }
20
21
        $decoded = json_decode($packet, true);
22
23
        return JSON_ERROR_NONE === json_last_error() && isset($decoded['job']);
24
    }
25
}
26