Completed
Push — master ( b67918...e9be8a )
by Ramon
13:39
created

ResponseParse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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 __call($name, $args)
18
    {
19
        if (!isset($this->response[$name])) {
20
            return null;
21
        }
22
23
        return $this->response[$name];
24
    }
25
26
    private function parse(string $response)
27
    {
28
        preg_match('/CertificadoBean : (.+)/', $response, $matches);
29
30
        $data = str_replace("'", "\"", $matches[1]);
31
32
        return json_decode($data, true);
33
    }
34
}
35