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

InteractsWithSwooleQueue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isSwooleQueuePacket() 0 9 3
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