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

ResponseParse::getResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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