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

RpcRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 77
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A setId() 0 4 1
A getMethod() 0 4 1
A setMethod() 0 4 1
A getVersion() 0 4 1
A get() 0 4 1
A export() 0 11 1
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
}