Passed
Push — master ( f2b4f1...f4fa9e )
by Dispositif
03:37
created

HttpClientFactory::create()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 1
b 0
f 1
cc 4
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Infrastructure;
11
12
use App\Application\InfrastructurePorts\HttpClientInterface;
13
use Exception;
14
15
class HttpClientFactory
16
{
17
    /**
18
     * @throws Exception si erreur Tor
19
     */
20
    public static function create(bool $tor = false): HttpClientInterface
21
    {
22
        if ($tor && getenv('TOR_PROXY') && getenv('TOR_CONTROL')) {
23
            return new TorClientAdapter();
24
        }
25
26
        return new GuzzleClientAdapter();
27
    }
28
}
29