Factory::getPointer()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 12
nc 6
nop 2
dl 0
loc 14
rs 9.2222
c 1
b 0
f 0
ccs 11
cts 11
cp 1
crap 6
1
<?php
2
3
namespace kalanis\RemoteRequest\Sockets;
4
5
6
use kalanis\RemoteRequest\Interfaces\IRRTranslations;
7
use kalanis\RemoteRequest\Interfaces\ISocket;
8
9
10
/**
11
 * Class Factory
12
 * @package kalanis\RemoteRequest\Sockets
13
 * Network sockets to the remote server - which can be used
14
 */
15
class Factory
16
{
17 1
    public static function getPointer(int $type = ISocket::SOCKET_STREAM, ?IRRTranslations $lang = null): ASocket
18
    {
19
        switch ($type) {
20 1
            case ISocket::SOCKET_INTERNAL:
21 1
                return new SharedInternal($lang);
22 1
            case ISocket::SOCKET_STREAM:
23 1
                return new Stream($lang);
24 1
            case ISocket::SOCKET_PFSOCKET:
25 1
                return new PfSocket($lang);
26 1
            case ISocket::SOCKET_SOCKET:
27 1
                return new Socket($lang);
28 1
            case ISocket::SOCKET_FSOCKET:
29
            default:
30 1
                return new FSocket($lang);
31
        }
32
    }
33
}
34