Tagging   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 7
c 1
b 0
f 1
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A inbound() 0 4 2
A exception() 0 3 1
A outbound() 0 3 1
A __construct() 0 3 1
1
<?php
2
/**
3
 * Request tagging
4
 * User: moyo
5
 * Date: 2018/7/25
6
 * Time: 2:52 PM
7
 */
8
9
namespace Carno\HRPC\Client;
10
11
use Carno\Chain\Layered;
12
use Carno\Coroutine\Context;
13
use Carno\RPC\Contracts\Client\Cluster;
14
use Carno\RPC\Protocol\Request;
15
use Carno\RPC\Protocol\Response;
16
use Throwable;
17
18
class Tagging implements Layered
19
{
20
    /**
21
     * @var Cluster
22
     */
23
    private $cluster = null;
24
25
    /**
26
     * Tagging constructor.
27
     * @param Cluster $cluster
28
     */
29
    public function __construct(Cluster $cluster)
30
    {
31
        $this->cluster = $cluster;
32
    }
33
34
    /**
35
     * @param Request $request
36
     * @param Context $ctx
37
     * @return Request
38
     */
39
    public function inbound($request, Context $ctx)
40
    {
41
        $request->hasTags() || $request->setTags(...$this->cluster->tags());
42
        return $request;
43
    }
44
45
    /**
46
     * @param Response $response
47
     * @param Context $ctx
48
     * @return Response
49
     */
50
    public function outbound($response, Context $ctx)
51
    {
52
        return $response;
53
    }
54
55
    /**
56
     * @param Throwable $e
57
     * @param Context $ctx
58
     * @throws Throwable
59
     */
60
    public function exception(Throwable $e, Context $ctx)
61
    {
62
        throw $e;
63
    }
64
}
65