Completed
Pull Request — master (#3)
by Sergey
02:17
created

JSONRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 1
dl 0
loc 49
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedMethods() 0 5 1
A getSource() 0 4 1
A makeEndPoint() 0 4 1
A formatRequestBody() 0 4 1
A parseResponse() 0 4 1
1
<?php
2
3
namespace seregazhuk\SmsIntel\Requests;
4
5
class JSONRequest extends Request
6
{
7
    const BASE_URL = 'https://lcab.smsintel.ru/lcabApi/';
8
9
    /**
10
     * @return array
11
     */
12
    public static function getAllowedMethods() {
13
        return [
14
            'getSource',
15
        ];
16
    }
17
18
    /**
19
     * @param string $source
20
     * @return array|null
21
     */
22
    public function getSource($source)
23
    {
24
        return $this->exec('requestSource', ['source' => $source]);
25
    }
26
27
    /**
28
     * @param string $action
29
     * @return string
30
     */
31
    protected function makeEndPoint($action)
32
    {
33
        return self::BASE_URL . $action . '.php';
34
    }
35
36
    /**
37
     * @param array $requestBody
38
     * @return mixed
39
     */
40
    protected function formatRequestBody(array $requestBody)
41
    {
42
        return $requestBody;
43
    }
44
45
    /**
46
     * @param string $response
47
     * @return array
48
     */
49
    protected function parseResponse($response)
50
    {
51
        return json_decode($response, true);
52
    }
53
}