Completed
Branch master (1d1574)
by Evgenij
18:38
created

AbstractClientSocket::createIoInterface()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5.3906

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 9
cts 12
cp 0.75
rs 8.8571
cc 5
eloc 12
nc 5
nop 2
crap 5.3906
1
<?php
2
/**
3
 * Async sockets
4
 *
5
 * @copyright Copyright (c) 2015-2016, Efimov Evgenij <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace AsyncSockets\Socket;
12
13
use AsyncSockets\Socket\Io\DatagramClientIo;
14
use AsyncSockets\Socket\Io\StreamedClientIo;
15
16
/**
17
 * Class AbstractClientSocket
18
 */
19
abstract class AbstractClientSocket extends AbstractSocket
20
{
21
    /** {@inheritdoc} */
22 34
    protected function createIoInterface($type, $address)
23
    {
24
        switch ($type) {
25 34
            case self::SOCKET_TYPE_UNIX:
26
                return new StreamedClientIo($this);
27 34
            case self::SOCKET_TYPE_TCP:
28 31
                return new StreamedClientIo($this);
29 3
            case self::SOCKET_TYPE_UDG:
30
                return new DatagramClientIo($this, null);
31 3
            case self::SOCKET_TYPE_UDP:
32
                return new DatagramClientIo($this, $address);
33 3
            default:
34 3
                throw new \LogicException("Unsupported socket resource type {$type}");
35 3
        }
36
    }
37
}
38