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

BaseTransport   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 41
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Transport;
5
6
abstract class BaseTransport implements TransportInterface
7
{
8
    /** @var resource|null|false */
9
    protected $target;
10
    protected string $schema = '';
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...
11
    protected WriterInterface $writer;
12
13
    public function __construct(WriterInterface $writer = null)
14
    {
15 16
        $this->writer = $writer ?? new Writer;
16
    }
17 16
18 16
    public function getWriter(): WriterInterface
19
    {
20 4
        return $this->writer;
21
    }
22 4
23
    public function write(string $buffer, int $length = null): int
24
    {
25
        return $this->writer->write($this->target, $buffer, $length);
26
    }
27
28
    public function isConnected(): bool
29
    {
30
        return is_resource($this->target) && !feof($this->target);
31 16
    }
32
33 16
    public function close(): void
34
    {
35
        $this->target && fclose($this->target);
36 12
        $this->target = null;
37
    }
38
}
39