UnderstandSyncHandler::send()   B
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 33
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 33
rs 8.8571
cc 3
eloc 18
nc 4
nop 1
1
<?php namespace UnderstandMonolog\Handler;
2
3
class UnderstandSyncHandler extends UnderstandBaseHandler
4
{
5
6
    /**
7
     * Send data to storage
8
     *
9
     * @param mixed $requestData
10
     * @return type
11
     */
12
    protected function send($requestData)
13
    {
14
        $endpoint = $this->getEndpoint();
15
        $ch = curl_init($endpoint);
16
17
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
18
        curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData);
19
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
20
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
21
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
22
23
        if ($this->sslBundlePath)
24
        {
25
            curl_setopt($ch, CURLOPT_CAINFO, $this->sslBundlePath);
26
        }
27
28
        curl_setopt($ch, CURLOPT_USERAGENT, 'Understand Monolog');
29
30
        $response = curl_exec($ch);
31
32
        if ($response === false)
33
        {
34
            $this->lastError = curl_error($ch);
35
        }
36
        else
37
        {
38
            $this->lastError = null;
39
        }
40
41
        curl_close($ch);
42
43
        return $response;
44
    }
45
}