SyncHandler::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php namespace Understand\UnderstandLaravel5\Handlers;
2
3
class SyncHandler extends BaseHandler
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
16
        $ch = curl_init($endpoint);
17
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
18
        curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData);
19
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
20
21
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
22
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
23
24
        if ($this->sslBundlePath)
25
        {
26
            curl_setopt($ch, CURLOPT_CAINFO, $this->sslBundlePath);
27
        }
28
29
        curl_setopt($ch, CURLOPT_USERAGENT, 'Laravel 5 service provider.');
30
31
        $response = curl_exec($ch);
32
33
        curl_close($ch);
34
35
        return $response;
36
    }
37
38
}
39