UnderstandSyncHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 43
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B send() 0 33 3
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
}