Specification::setMethods()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 4
nc 5
nop 1
1
<?php
2
/**
3
 * Service specification
4
 * User: moyo
5
 * Date: 21/09/2017
6
 * Time: 10:50 AM
7
 */
8
9
namespace Carno\RPC\Service;
10
11
class Specification
12
{
13
    /**
14
     * @var string
15
     */
16
    private $server = null;
17
18
    /**
19
     * @var string
20
     */
21
    private $service = null;
22
23
    /**
24
     * @var array
25
     */
26
    private $methodRequests = [];
27
28
    /**
29
     * @var array
30
     */
31
    private $methodResponses = [];
32
33
    /**
34
     * Specification constructor.
35
     * @param string $server
36
     * @param string $service
37
     */
38
    public function __construct(string $server, string $service)
39
    {
40
        $this->server = $server;
41
        $this->service = $service;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getServer() : string
48
    {
49
        return $this->server;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getService() : string
56
    {
57
        return $this->service;
58
    }
59
60
    /**
61
     * @param array $methodRRs
62
     * @return static
63
     */
64
    public function setMethods(array $methodRRs) : self
65
    {
66
        foreach ($methodRRs as $methodName => $rrs) {
67
            isset($rrs['in']) && $this->methodRequests[$methodName] = $rrs['in'];
68
            isset($rrs['out']) && $this->methodResponses[$methodName] = $rrs['out'];
69
        }
70
        return $this;
71
    }
72
73
    /**
74
     * @param string $method
75
     * @return string
76
     */
77
    public function getMethodRequest(string $method) : string
78
    {
79
        return $this->methodRequests[$method] ?? '';
80
    }
81
82
    /**
83
     * @param string $method
84
     * @return string
85
     */
86
    public function getMethodResponse(string $method) : string
87
    {
88
        return $this->methodResponses[$method] ?? '';
89
    }
90
}
91