Passed
Branch master (1e7e1e)
by Kris
01:37
created

CurlTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 16
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setCurlOption() 0 3 2
1
<?php
2
3
/**
4
 *     _    _                    ___ ____  ____  ____
5
 *    / \  | |__  _   _ ___  ___|_ _|  _ \|  _ \| __ )
6
 *   / _ \ | '_ \| | | / __|/ _ \| || |_) | | | |  _ \
7
 *  / ___ \| |_) | |_| \__ \  __/| ||  __/| |_| | |_) |
8
 * /_/   \_\_.__/ \__,_|___/\___|___|_|   |____/|____/
9
 *
10
 * This file is part of Kristuff\AbsuseIPDB.
11
 *
12
 * (c) Kristuff <[email protected]>
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 *
17
 * @version    0.9.7
18
 * @copyright  2020-2021 Kristuff
19
 */
20
21
namespace Kristuff\AbuseIPDB;
22
23
/**
24
 * cURL helper functions
25
 */
26
trait CurlTrait
27
{
28
    /**
29
     * helper to configure cURL option
30
     *  
31
     * @access protected
32
     * @param resource  $ch
33
     * @param int       $option
34
     * @param mixed     $value
35
     *   
36
     * @return void
37
     * @throws \RuntimeException
38
     */
39
    protected function setCurlOption($ch,int $option,$value){
40
        if(!curl_setopt($ch,$option,$value)){
41
            throw new \RuntimeException('curl_setopt failed! '.curl_error($ch));
42
        }
43
    }
44
}
45