Novocom::getUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sarahman\SmsService\Providers;
4
5
use Sarahman\SmsService\Response;
6
7
class Novocom extends BaseProvider
8
{
9
    public function getUsername()
10
    {
11
        return $this->config['ClientId'];
12
    }
13
14
    public function mapParams($recipient, $message, array $params = [])
15
    {
16
        if (!preg_match($this->recipientPattern, $recipient, $matches)) {
17
            return [];
18
        }
19
20
        $recipient = '880'.$matches[3];
21
22
        return [
23
            'MobileNumbers' => $recipient,
24
            'Message'       => $message,
25
        ];
26
    }
27
28
    public function getValidationRules()
29
    {
30
        return [
31
            'ClientId'      => 'required',
32
            'ApiKey'        => 'required',
33
            'SenderId'      => 'required',
34
            'MobileNumbers' => 'required|regex:/^8801[3456789]\d{8}$/',
35
            'Message'       => 'required',
36
        ];
37
    }
38
39
    public function parseResponse($response)
40
    {
41
        $parsedResponse = json_decode($response);
42
43
        return new Response(0 === (int) $parsedResponse->ErrorCode, $response);
44
    }
45
}
46