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

HttpClientFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 4
dl 0
loc 12
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 4
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