Completed
Push — master ( 77d207...af47af )
by Atymic
05:06
created

Sns   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 14 1
A __construct() 0 3 1
1
<?php
2
3
namespace NotificationChannels\AwsSns;
4
5
use Aws\Exception\AwsException;
6
use Aws\Sns\SnsClient as SnsService;
7
8
class Sns
9
{
10
    /**
11
     * @var SnsService
12
     */
13
    protected $snsService;
14
15 3
    public function __construct(SnsService $snsService)
16
    {
17 3
        $this->snsService = $snsService;
18 3
    }
19
20
    /**
21
     * @param SnsMessage $message
22
     * @param $destination
23
     * @return \Aws\Result
24
     * @throws AwsException
25
     */
26 2
    public function send(SnsMessage $message, $destination)
27
    {
28
        $parameters = [
29 2
            'Message' => $message->getBody(),
30 2
            'PhoneNumber' => $destination,
31
            'MessageAttributes' => [
32
                'AWS.SNS.SMS.SMSType' => [
33 2
                    'DataType' => 'String',
34 2
                    'StringValue' => $message->getDeliveryType(),
35
                ],
36
            ],
37
        ];
38
39 2
        return $this->snsService->publish($parameters);
40
    }
41
}
42