Completed
Pull Request — master (#3)
by
unknown
04:36
created

Sns::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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