Passed
Push — master ( 2cd332...0af4da )
by Ross
02:35
created

CurlResource::curlClose()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 *
4
 * Copyright (C) 2018  Ross Mitchell
5
 *
6
 * This file is part of RossMitchell/UpdateCloudFlare.
7
 *
8
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
9
 * it and/or modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace RossMitchell\UpdateCloudFlare\Helpers;
23
24
25
use RossMitchell\UpdateCloudFlare\Interfaces\CurlResourceInterface;
26
27
/**
28
 * Class CurlResource - This is a way of further abstracting the curl calls out of a class to help with testing
29
 * @package RossMitchell\UpdateCloudFlare\Helpers
30
 */
31
class CurlResource implements CurlResourceInterface
32
{
33
34
    /**
35
     * Used To initialise the curl resource
36
     *
37
     * @return resource
38
     */
39
    public function curlInit()
40
    {
41
        return \curl_init();
42
    }
43
44
    /**
45
     * Used to set a curl option
46
     *
47
     * @param resource $curl
48
     * @param int      $option
49
     * @param mixed    $value
50
     *
51
     * @return void
52
     */
53
    public function setOption($curl, int $option, $value): void
54
    {
55
        \curl_setopt($curl, $option, $value);
56
    }
57
58
    /**
59
     * Used to make the curl request
60
     *
61
     * @param $curl
62
     *
63
     * @return mixed
64
     */
65
    public function curlExec($curl)
66
    {
67
        return \curl_exec($curl);
68
    }
69
70
    /**
71
     * Used to check if there has been an error with the request
72
     *
73
     * @param $curl
74
     *
75
     * @return mixed
76
     */
77
    public function curlError($curl)
78
    {
79
        return \curl_error($curl);
80
    }
81
82
    /**
83
     * Used to close the connection
84
     *
85
     * @param $curl
86
     *
87
     * @return void
88
     */
89
    public function curlClose($curl): void
90
    {
91
        \curl_close($curl);
92
    }
93
}
94