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

ClientSocket::createSocketResource()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 9.4285
cc 3
eloc 11
nc 2
nop 2
crap 3
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