Cluster   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 3
c 5
b 1
f 1
lcom 1
cbo 4
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A meet() 0 21 3
1
<?php
2
namespace Phloppy\Client;
3
4
use Phloppy\Exception;
5
use Phloppy\Exception\CommandException;
6
use Phloppy\Stream\StreamException;
7
8
/**
9
 * Disque cluster commands.
10
 *
11
 * @see http://redis.io/commands#cluster
12
 */
13
class Cluster extends AbstractClient {
14
15
16
    /**
17
     * Introduce the provided nodes to the connected Disque instance.
18
     *
19
     * @param string[] $nodeUrls
20
     *
21
     * @return string[]
22
     * @see http://redis.io/commands/cluster-meet
23
     */
24 3
    public function meet(array $nodeUrls)
25
    {
26 3
        $current = $this->stream->getNodeUrl();
27
28 3
        return array_filter($nodeUrls, function($url) use ($current) {
29 3
            if ($url === $current) {
30 1
                return true;
31
            }
32
33 2
            $parts = parse_url($url);
34
35
            try {
36 2
                $response = $this->send(['CLUSTER', 'MEET', $parts['host'], (int) $parts['port']]);
37 2
                $this->log->debug('CLUSTER MEET', ['host' => $url, 'response' => $response]);
38 2
                return 'OK' === $response;
39 1
            } catch (Exception $e) {
40 1
                $this->log->error($e->getMessage(), array('url' => $url, 'exception' => $e));
41 1
                return false;
42
            }
43 3
        });
44
    }
45
}
46