SqsQueueStoreConnection::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 2
b 0
f 1
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
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