Passed
Push — devel-3.0 ( 30ba17...7f31cf )
by Rubén
03:41
created

Client   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOptions() 0 16 4
1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
8
 *
9
 * This file is part of sysPass.
10
 *
11
 * sysPass is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * sysPass is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 *  along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
namespace SP\Http;
26
27
use SP\Config\ConfigData;
28
29
/**
30
 * Class Client
31
 *
32
 * @package SP\Http
33
 */
34
class Client
35
{
36
    /**
37
     * @param ConfigData $configData
38
     *
39
     * @return array
40
     */
41
    public static function getOptions(ConfigData $configData)
42
    {
43
        $options = [
44
            'timeout' => 10,
45
            'version' => 1.1
46
        ];
47
48
        if ($configData->isProxyEnabled()) {
49
            $options['proxy'] = sprintf('tcp://%s:%d', $configData->getProxyServer(), $configData->getProxyPort());
50
51
            if (!empty($configData->getProxyUser()) && !empty($configData->getProxyPass())) {
52
                $options['auth'] = [$configData->getProxyUser(), $configData->getProxyPass()];
53
            }
54
        }
55
56
        return $options;
57
    }
58
}