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

UdpSocket   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 5 1
A isConnected() 0 4 2
A close() 0 5 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