Completed
Push — master ( 339dcc...fa58da )
by Daniel
13:39
created

RpcRequest::export()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Rpc\Request;
4
5
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
6
7
8
class RpcRequest implements RpcRequestInterface
9
{
10
    const VERSION = '2.0';
11
12
    public $id;
13
    public $method;
14
    public $attributes;
15
16
    public function __construct($id = null, $method = null, array $attributes = [])
17
    {
18
        $this->id = $id;
19
        $this->method = $method;
20
        $this->attributes = new ParameterBag($attributes);
21
    }
22
23
    /**
24
     * @return int|string
25
     */
26
    public function getId()
27
    {
28
        return $this->id;
29
    }
30
31
    /**
32
     * @param int|string $id
33
     */
34
    public function setId($id)
35
    {
36
        $this->id = $id;
37
    }
38
39
40
    /**
41
     * @return string
42
     */
43
    public function getMethod()
44
    {
45
        return $this->method;
46
    }
47
48
    /**
49
     * @param string $method
50
     */
51
    public function setMethod($method)
52
    {
53
        $this->method = $method;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getVersion()
60
    {
61
        return self::VERSION;
62
    }
63
64
    /**
65
     * @param $key
66
     * @return mixed
67
     */
68
    public function get($key)
69
    {
70
        return $this->attributes->get($key);
71
    }
72
73
    public function export()
74
    {
75
        $rpc = [
76
            'id' => $this->id,
77
            'jsonrpc' => self::VERSION,
78
            'method' => $this->method,
79
            'params' => $this->attributes->all()
80
        ];
81
82
        return $rpc;
83
    }
84
}