Completed
Push — master ( 15ad7c...0efd86 )
by Maik
04:38
created

HttpClientFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the PHP Generics package.
4
 *
5
 * @package Generics
6
 */
7
namespace Generics\Client;
8
9
use Generics\Socket\Url;
10
use Generics\Streams\HttpStream;
11
12
/**
13
 * This class provides a factory for http(s) clients
14
 *
15
 * @author Maik Greubel <[email protected]>
16
 */
17
final class HttpClientFactory
18
{
19
20
    private function __construct()
21
    {
22
        // Nothing
23
    }
24
25
    /**
26
     * Create a new instance of Http(s) client for given url
27
     *
28
     * @param Url $url
29
     *            The url to create a http(s) client instance for
30
     *            
31
     * @return HttpStream
32
     */
33 2
    public static function get(Url $url): HttpStream
34
    {
35 2
        if ($url->getScheme() === 'https') {
36 1
            return new HttpsClient($url);
37
        }
38 1
        return new HttpClient($url);
39
    }
40
}