Code Duplication    Length = 11-13 lines in 4 locations

src/phpsms/agents/JuHeAgent.php 1 location

@@ 55-65 (lines=11) @@
52
        $this->setResult($result);
53
    }
54
55
    protected function setResult($result)
56
    {
57
        if ($result['request']) {
58
            $this->result(Agent::INFO, $result['response']);
59
            $result = json_decode($result['response'], true);
60
            $this->result(Agent::SUCCESS, $result['error_code'] === 0);
61
            $this->result(Agent::CODE, $result['error_code']);
62
        } else {
63
            $this->result(Agent::INFO, 'request failed');
64
        }
65
    }
66
}
67

src/phpsms/agents/LuosimaoAgent.php 1 location

@@ 53-63 (lines=11) @@
50
        $this->setResult($result);
51
    }
52
53
    protected function setResult($result)
54
    {
55
        if ($result['request']) {
56
            $this->result(Agent::INFO, $result['response']);
57
            $result = json_decode($result['response'], true);
58
            $this->result(Agent::SUCCESS, $result['error'] === 0);
59
            $this->result(Agent::CODE, $result['error']);
60
        } else {
61
            $this->result(Agent::INFO, 'request failed');
62
        }
63
    }
64
}
65

src/phpsms/agents/SendCloudAgent.php 1 location

@@ 68-80 (lines=13) @@
65
        return md5($stringToBeSigned);
66
    }
67
68
    protected function setResult($result)
69
    {
70
        if ($result['request']) {
71
            $this->result(Agent::INFO, $result['response']);
72
            $result = json_decode($result['response'], true);
73
            if (isset($result['result'])) {
74
                $this->result(Agent::SUCCESS, (bool) $result['result']);
75
                $this->result(Agent::CODE, $result['statusCode']);
76
            }
77
        } else {
78
            $this->result(Agent::INFO, 'request failed');
79
        }
80
    }
81
82
    protected function getTempDataString(array $data)
83
    {

src/phpsms/agents/YunPianAgent.php 1 location

@@ 52-62 (lines=11) @@
49
        $this->setResult($result);
50
    }
51
52
    protected function setResult($result)
53
    {
54
        if ($result['request']) {
55
            $this->result(Agent::INFO, $result['response']);
56
            $result = json_decode($result['response'], true);
57
            $this->result(Agent::SUCCESS, $result['code'] === 0);
58
            $this->result(Agent::CODE, $result['code']);
59
        } else {
60
            $this->result(Agent::INFO, 'request failed');
61
        }
62
    }
63
}
64