Factory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 33
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B getProtocol() 0 25 8
1
<?php
2
3
namespace kalanis\RemoteRequest\Protocols;
4
5
6
use kalanis\RemoteRequest;
7
8
9
/**
10
 * Class Factory
11
 * @package kalanis\RemoteRequest\Protocols
12
 * Factory to select correct layer for protocol
13
 */
14
class Factory
15
{
16
    /**
17
     * @param string $schema
18
     * @param RemoteRequest\Interfaces\IRRTranslations $lang
19
     * @throws RemoteRequest\RequestException
20
     * @return AProtocol
21
     */
22 2
    public static function getProtocol(string $schema, RemoteRequest\Interfaces\IRRTranslations $lang): AProtocol
23
    {
24
        switch ($schema) {
25 2
            case 'tcp':
26 2
            case 'file':
27 1
                return new Tcp();
28 2
            case 'udp':
29 1
                return new Udp();
30 2
            case 'fsp':
31 1
                return new Fsp();
32 2
            case 'http':
33 2
            case 'https':
34 1
                return new Http();
35
//            case 'http2':
36
//                return new Http2();
37
//            case 'http3':
38
//                return new Http3();
39 2
            case 'webdav':
40 1
                return new WebDAV();
41
//            case 'smb':
42
//                return new Samba();
43
//            case 'git':
44
//                return new Git();
45
            default:
46 1
                throw new RemoteRequest\RequestException($lang->rrSchemaUnknownResponse($schema));
47
        }
48
    }
49
}
50