Stream   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

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

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
0 ignored issues
show
introduced by
Missing declare(strict_types=1).
Loading history...
2
3
namespace ClickHouseDB\Transport;
4
5
/**
6
 * Class Stream
0 ignored issues
show
introduced by
Documentation comment contains forbidden comment "Class Stream".
Loading history...
7
 * @package ClickHouseDB\Transport
0 ignored issues
show
introduced by
Expected 1 lines between description and annotations, found 0.
Loading history...
introduced by
Use of annotation @package is forbidden.
Loading history...
8
 */
9
abstract class Stream implements IStream
10
{
11
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\Stream::$source with single line content, use one-line comment instead.
Loading history...
12
     * @var resource
13
     */
14
    private $source;
15
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\Stream::$gzip with single line content, use one-line comment instead.
Loading history...
16
     * @var bool
17
     */
18
    private $gzip=false;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
19
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\Stream::$callable with single line content, use one-line comment instead.
Loading history...
20
     * @var null|callable
0 ignored issues
show
introduced by
Null type hint should be on last position in "null|callable".
Loading history...
21
     */
22
    private $callable=null;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
23
    /**
24
     * @param resource $source
25
     */
26 2
    public function __construct($source)
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before function; 0 found
Loading history...
27
    {
28 2
        if (!is_resource($source)) {
0 ignored issues
show
introduced by
Function is_resource() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Expected 1 lines after "if", found 0.
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
29
            throw new \InvalidArgumentException('Argument $source must be resource');
0 ignored issues
show
introduced by
Class \InvalidArgumentException should not be referenced via a fully qualified name, but via a use statement.
Loading history...
30
        }
31 2
        $this->source = $source;
32 2
    }
33
34
    /**
35
     * @return bool
36
     */
37 2
    public function isGzipHeader()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\Stream::isGzipHeader() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
38
    {
39 2
        return $this->gzip;
40
    }
41
42
    /**
43
     * @return callable|null
44
     */
45 2
    public function getClosure()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\Stream::getClosure() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "callable|null".
Loading history...
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
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\Stream::closure() has useless @param annotation for parameter $callable.
Loading history...
60
     */
61 2
    public function closure(callable $callable)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\Stream::closure() does not have void return type hint.
Loading history...
introduced by
Method \ClickHouseDB\Transport\Stream::closure() does not need documentation comment.
Loading history...
62
    {
63 2
        $this->callable=$callable;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
64 2
    }
65
66
    /**
0 ignored issues
show
introduced by
Empty comment
Loading history...
67
     *
68
     */
69 1
    public function enableGzipHeader()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\Stream::enableGzipHeader() does not have void return type hint.
Loading history...
introduced by
Method \ClickHouseDB\Transport\Stream::enableGzipHeader() does not need documentation comment.
Loading history...
70
    {
71 1
        $this->gzip=true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
72 1
    }
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after function; 1 found
Loading history...
73
74
}
0 ignored issues
show
introduced by
There must be exactly 0 empty lines before class closing brace.
Loading history...
75