Completed
Push — master ( 5c78d7...6647db )
by thomas
8s
created

Response::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace BitWasp\Stratum\Request;
4
5
class Response
6
{
7
    /**
8
     * @var int|string
9
     */
10
    private $id;
11
12
    /**
13
     * @var mixed
14
     */
15
    private $result;
16
17
    /**
18
     * @param int|string $id
19
     * @param mixed $result
20
     */
21 5
    public function __construct($id, $result)
22
    {
23 5
        $this->id = $id;
24 5
        $this->result = $result;
25 5
    }
26
27
    /**
28
     * @return int|string
29
     */
30 5
    public function getId()
31
    {
32 5
        return $this->id;
33
    }
34
35
    /**
36
     * @return mixed
37
     */
38 2
    public function getResult()
39
    {
40 2
        return $this->result;
41
    }
42
43
    /**
44
     * @return string
45
     */
46 2
    public function write()
47
    {
48 2
        return json_encode([
49 2
            'id' => $this->id,
50 2
            'result' => $this->result
51 2
        ]) . "\n";
52
    }
53
}
54