Paystation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A mapParams() 0 12 2
A getUsername() 0 3 1
A parseResponse() 0 5 1
A getValidationRules() 0 8 1
1
<?php
2
3
namespace Sarahman\SmsService\Providers;
4
5
use Sarahman\SmsService\Response;
6
7
class Paystation extends BaseProvider
8
{
9
    public function getUsername()
10
    {
11
        return $this->config['user_id'];
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 = '0'.$matches[3];
21
22
        return [
23
            'type'    => $this->config['type'],
24
            'number'  => $recipient,
25
            'message' => $message,
26
        ];
27
    }
28
29
    public function getValidationRules()
30
    {
31
        return [
32
            'user_id'  => 'required',
33
            'password' => 'required',
34
            'type'     => 'required',
35
            'number'   => 'required|regex:/^01[3456789]\d{8}$/',
36
            'message'  => 'required',
37
        ];
38
    }
39
40
    public function parseResponse($response)
41
    {
42
        $parsedResponse = json_decode($response);
43
44
        return new Response('success' === strtolower($parsedResponse->status), $response);
45
    }
46
}
47