SqsQueueStoreConnection::connect()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
c 3
b 0
f 1
nc 1
nop 0
dl 0
loc 12
ccs 9
cts 9
cp 1
crap 1
rs 9.9666
1
<?php
2
3
namespace Da\Mailer\Queue\Backend\Sqs;
4
5
use Aws\Sqs\SqsClient;
6
use Da\Mailer\Queue\Backend\AbstractQueueStoreConnection;
7
8
class SqsQueueStoreConnection extends AbstractQueueStoreConnection
9
{
10
    /**
11
     * SqsQueueStoreConnection constructor.
12
     *
13
     * @param array $configuration
14 2
     */
15
    public function __construct(array $configuration = [])
16 2
    {
17 2
        parent::__construct($configuration);
18
    }
19
20
    /**
21
     * @return $this
22 1
     */
23
    public function connect()
24 1
    {
25 1
        $this->disconnect();
26 1
        $key = $this->getConfigurationValue('key');
27 1
        $secret = $this->getConfigurationValue('secret');
28
        $region = $this->getConfigurationValue('region');
29 1
        $this->instance = new SqsClient([
30 1
            'key' => $key,
31 1
            'secret' => $secret,
32 1
            'region' => $region,
33 1
        ]);
34
        return $this;
35 1
    }
36
37
    /**
38
     * Returns the connection instance.
39
     *
40
     * @return SqsClient
41
     */
42
    public function getInstance()
43 1
    {
44
        if ($this->instance === null) {
45 1
            $this->connect();
46 1
        }
47 1
48
        return $this->instance;
49 1
    }
50
}
51