SqsQueueStoreConnection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 14
c 3
b 0
f 1
dl 0
loc 41
ccs 18
cts 18
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getInstance() 0 7 2
A connect() 0 12 1
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