Issues (52)

src/Queue/Driver/Message.php (3 issues)

1
<?php
2
3
namespace Freyo\LaravelQueueCMQ\Queue\Driver;
4
5
class Message
6
{
7
    public $msgBody;
8
    public $msgId;
9
    public $enqueueTime;
10
    public $receiptHandle;
11
12
    /* 消息属性
13
14
        @note: send_message 指定属性
15
        :: msgBody         消息体
16
17
        @note: send_message 返回属性
18
        :: msgId           消息编号
19
20
        @note: receive_message 返回属性,除基本属性外
21
        :: receiptHandle       下次删除或修改消息的临时句柄
22
        :: enqueueTime         消息入队时间
23
        :: nextVisibleTime     下次可被再次消费的时间
24
        :: dequeueCount        总共被消费的次数
25
        :: firstDequeueTime    第一次被消费的时间
26
    */
27
    public function __construct($message_body = '')
28
    {
29
        $this->msgBody = $message_body;
30
        $this->msgId = '';
31
        $this->enqueueTime = -1;
32
        $this->receiptHandle = '';
33
        $this->nextVisibleTime = -1;
0 ignored issues
show
Bug Best Practice introduced by
The property nextVisibleTime does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
34
        $this->dequeueCount = -1;
0 ignored issues
show
Bug Best Practice introduced by
The property dequeueCount does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        $this->firstDequeueTime = -1;
0 ignored issues
show
Bug Best Practice introduced by
The property firstDequeueTime does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
    }
37
38
    public function __toString()
39
    {
40
        $info = ['msgBody'               => $this->msgBody,
41
                      'msgId'            => $this->msgId,
42
                      'enqueueTime'      => date('Y-m-d H:i:s', $this->enqueueTime),
43
                      'nextVisibleTime'  => date('Y-m-d H:i:s', $this->nextVisibleTime),
44
                      'firstDequeueTime' => date('Y-m-d H:i:s', $this->firstDequeueTime),
45
                      'dequeueCount'     => $this->dequeueCount,
46
                      'receiptHandle'    => $this->receiptHandle, ];
47
48
        return json_encode($info);
49
    }
50
}
51