BaseResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 62
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
parse() 0 1 ?
A __construct() 0 4 1
A setReader() 0 4 1
A setReceiver() 0 4 1
1
<?php
2
namespace Disque\Connection\Response;
3
4
use Closure;
5
6
abstract class BaseResponse
7
{
8
    /**
9
     * Data
10
     *
11
     * @var string
12
     */
13
    protected $data;
14
15
    /**
16
     * Reader
17
     *
18
     * @var Closure
19
     */
20
    protected $reader;
21
22
    /**
23
     * Receiver
24
     *
25
     * @var Closure
26
     */
27
    protected $receiver;
28
29
    /**
30
     * Create instance
31
     *
32
     * @param string $data
33
     */
34
    public function __construct($data)
35
    {
36
        $this->data = substr($data, 0, -2); // Get rid of last CRLF
37
    }
38
39
    /**
40
     * Set reader
41
     *
42
     * @param Closure $reader Reader function
43
     * @return void
44
     */
45
    public function setReader(Closure $reader)
46
    {
47
        $this->reader = $reader;
48
    }
49
50
    /**
51
     * Set receiver
52
     *
53
     * @param Closure $receiver Receiver function
54
     * @return void
55
     */
56
    public function setReceiver(Closure $receiver)
57
    {
58
        $this->receiver = $receiver;
59
    }
60
61
    /**
62
     * Parse response
63
     *
64
     * @return mixed Response
65
     */
66
    abstract public function parse();
67
}