CurlRequester   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A request() 0 16 1
1
<?php
2
3
namespace DingRobot\Requester;
4
5
use DingRobot\Contract\RequesterContract;
6
7
class CurlRequester implements RequesterContract
8
{
9
    public function request($remote_server, $post_string)
10
    {
11
        $ch = curl_init();
12
        curl_setopt($ch, CURLOPT_URL, $remote_server);
13
        curl_setopt($ch, CURLOPT_POST, 1);
14
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
15
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json;charset=utf-8'));
16
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
17
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
18
        // 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
19
        // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
20
        // curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
        $data = curl_exec($ch);
22
        curl_close($ch);
23
24
        return $data;
25
    }
26
}