Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

SqsJob::read()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Q\Job;
3
4
use Aws\Sqs\SqsClient;
5
use Wandu\Q\Contracts\JobInterface;
6
7
class SqsJob implements JobInterface
8
{
9
    /** @var \Aws\Sqs\SqsClient */
10
    protected $client;
11
12
    /** @var string */
13
    protected $url;
14
15
    /** @var string */
16
    protected $body;
17
18
    /** @var string */
19
    protected $handle;
20
21
    /**
22
     * @param \Aws\Sqs\SqsClient $client
23
     * @param string $url
24
     * @param string $handle
25
     * @param string $body
26
     */
27
    public function __construct(SqsClient $client, $url, $handle, $body)
28
    {
29
        $this->client = $client;
30
        $this->url = $url;
31
        $this->handle = $handle;
32
        $this->body = $body;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function read()
39
    {
40
        return $this->body;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function delete()
47
    {
48
        return $this->client->deleteMessage([
49
            'QueueUrl'  => $this->url,
50
            'ReceiptHandle' => $this->handle,
51
        ]);
52
    }
53
}
54