Completed
Push — master ( 589ef2...1d7422 )
by
unknown
14:54
created

ResponseParse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 35
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResponse() 0 4 1
A __call() 0 8 2
A parse() 0 8 1
1
<?php
2
3
namespace Codecraft63\CertsignLogin;
4
5
class ResponseParse
6
{
7
    private $raw_response;
8
9
    private $response;
10
11
    public function __construct(string $response)
12
    {
13
        $this->raw_response = $response;
14
        $this->response = $this->parse($response);
15
    }
16
17
    public function getResponse()
18
    {
19
        return $this->response;
20
    }
21
22
    public function __call($name, $args)
23
    {
24
        if (!isset($this->response[$name])) {
25
            return null;
26
        }
27
28
        return $this->response[$name];
29
    }
30
31
    private function parse(string $response)
32
    {
33
        preg_match('/CertificadoBean : (.+\})/', $response, $matches);
34
35
        $data = str_replace("'", "\"", $matches[1]);
36
37
        return json_decode($data, true);
38
    }
39
}
40