Passed
Push — master ( dde472...6978f3 )
by Alexpts
01:57
created

Socket::isConnected()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Transport;
5
6
class Socket extends BaseTransport
7
{
8
9
    /**
10
     * @param string $address
11
     * @param array $options
12
     *
13
     * @return TransportInterface
14
     */
15
    public function connect(string $address, array $options = []): TransportInterface
16
    {
17
        $timeout = (float)($options['timeout'] ??(float) ini_get('default_socket_timeout'));
18
        $port = $options['port'] ?? 0;
19
        $url = $this->schema . $address;
20
        $this->target = @fsockopen($url, $port, $this->errorNumber, $this->errorMessage, $timeout);
21
22
        return $this;
23
    }
24
}
25