CurlTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

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