Completed
Pull Request — master (#101)
by Hiraku
05:27
created

Share::setup()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
1
<?php
2
namespace Hirak\Prestissimo;
3
4
class Share
5
{
6
    public static function setup($ch)
7
    {
8
        static $sh;
9
10
        if (!function_exists('curl_share_init')) {
11
            return;
12
        }
13
14
        if (!$sh) {
15
            $sh = curl_share_init();
16
            curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
17
            curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
18
        }
19
20
        curl_setopt($ch, CURLOPT_SHARE, $sh);
21
    }
22
}
23