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

ResponseParse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 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 __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