Subscribe   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
1
<?php
2
/**
3
 * NSQd subscribe
4
 * User: moyo
5
 * Date: 02/03/2018
6
 * Time: 11:47 AM
7
 */
8
9
namespace Carno\NSQ\Protocol;
10
11
use function Carno\Coroutine\go;
12
use Carno\NSQ\Connector\Nsqd;
13
use Carno\NSQ\Types\Consuming;
14
use Carno\Promise\Promised;
15
16
class Subscribe
17
{
18
    /**
19
     * Subscribe constructor.
20
     * @param Promised $connected
21
     * @param Nsqd $nsqd
22
     * @param Consuming $consuming
23
     */
24
    public function __construct(Promised $connected, Nsqd $nsqd, Consuming $consuming)
25
    {
26
        go(static function () use ($connected, $nsqd, $consuming) {
27
            if (yield $connected) {
28
                if (yield $nsqd->sub($consuming->topic(), $consuming->channel())) {
29
                    $nsqd->rdy($consuming->concurrency());
30
                }
31
            }
32
        });
33
    }
34
}
35