Passed
Push — master ( 7b4f81...84e0ca )
by Igor
03:22
created

Stream   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 63
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A closure() 0 3 1
A isGzipHeader() 0 3 1
A enableGzipHeader() 0 3 1
A getStream() 0 3 1
A __construct() 0 6 2
A getClosure() 0 3 1
1
<?php
2
3
namespace ClickHouseDB\Transport;
4
5
/**
6
 * Class Stream
7
 * @package ClickHouseDB\Transport
8
 */
9
abstract class Stream implements IStream
10
{
11
    /**
12
     * @var resource
13
     */
14
    private $source;
15
    /**
16
     * @var bool
17
     */
18
    private $gzip=false;
19
    /**
20
     * @var null|callable
21
     */
22
    private $callable=null;
23
    /**
24
     * @param resource $source
25
     */
26 2
    public function __construct($source)
27
    {
28 2
        if (!is_resource($source)) {
29
            throw new \InvalidArgumentException('Argument $source must be resource');
30
        }
31 2
        $this->source = $source;
32 2
    }
33
34
    /**
35
     * @return bool
36
     */
37 2
    public function isGzipHeader()
38
    {
39 2
        return $this->gzip;
40
    }
41
42
    /**
43
     * @return callable|null
44
     */
45 2
    public function getClosure()
46
    {
47 2
        return $this->callable;
48
    }
49
50
    /**
51
     * @return resource
52
     */
53 2
    public function getStream()
54
    {
55 2
        return $this->source;
56
    }
57
58
    /**
59
     * @param callable $callable
60
     */
61 2
    public function closure(callable $callable)
62
    {
63 2
        $this->callable=$callable;
64 2
    }
65
66
    /**
67
     *
68
     */
69 1
    public function enableGzipHeader()
70
    {
71 1
        $this->gzip=true;
72 1
    }
73
74
}
75