Completed
Push — master ( 1cb211...95ea2a )
by Evgenij
03:22
created

ClientSocket::createIoInterface()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 12.4085

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 15
ccs 4
cts 12
cp 0.3333
rs 8.8571
cc 5
eloc 12
nc 5
nop 2
crap 12.4085
1
<?php
2
/**
3
 * Async sockets
4
 *
5
 * @copyright Copyright (c) 2015, 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\Exception\NetworkSocketException;
14
15
/**
16
 * Class ClientSocket
17
 */
18
class ClientSocket extends AbstractClientSocket
19
{
20
    /** {@inheritdoc} */
21 14
    protected function createSocketResource($address, $context)
22
    {
23 14
        $resource = stream_socket_client(
24 14
            $address,
25 14
            $errno,
26 14
            $errstr,
27 14
            null,
28 14
            STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT,
29
            $context
30 14
        );
31
32 14
        if ($errno || $resource === false) {
33 2
            throw new NetworkSocketException($this, $errstr, $errno);
34
        }
35
36 12
        return $resource;
37
    }
38
}
39