Test Setup Failed
Push — master ( 246aa3...2d0e6f )
by Alexpts
01:50
created

Socket::connect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Transport;
5
6
class Socket extends BaseTransport
7
{
8
9
    protected int $errorNumber = 0;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
10
    protected string $errorMessage = '';
11
12
    public function connect(string $address, array $options = []): static
13
    {
14
        if ($this->target === null) {
15
            $timeout = (float)($options['timeout'] ??(float) ini_get('default_socket_timeout'));
16
            $port = $options['port'] ?? 0;
17
            $url = $this->schema . $address;
18 12
            $this->target = fsockopen($url, $port, $this->errorNumber, $this->errorMessage, $timeout);
19
        }
20 12
21 12
        return $this;
22 12
    }
23
}
24