Completed
Push — master ( 89265b...110e58 )
by Alexpts
01:59
created

UdpSocket::connect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Transport\Udp;
5
6
use PTS\Transport\Socket;
7
use PTS\Transport\TransportInterface;
8
9
class UdpSocket extends Socket
10
{
11
12
    /** @var bool */
13
    protected $isConnected = false;
14
    /** @var string  */
15
    protected $schema = 'udp://';
16
17 4
    public function connect(string $address, array $options = []): TransportInterface
18
    {
19 4
        $this->isConnected = true;
20 4
        return parent::connect($address, $options);
21
    }
22
23 4
    public function isConnected(): bool
24
    {
25 4
        return $this->isConnected && $this->target !== null;
26
    }
27
28 4
    public function close(): void
29
    {
30 4
        parent::close();
31 4
        $this->isConnected = false;
32 4
    }
33
}
34