NullPrioritizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sort() 0 13 2
1
<?php
2
namespace Disque\Connection\Node;
3
4
/**
5
 * This prioritizer always advises to stay on the current node
6
 */
7
class NullPrioritizer implements NodePrioritizerInterface
8
{
9
    /**
10
     * @inheritdoc
11
     */
12
    public function sort(array $nodes, $currentNodeId)
13
    {
14
        if (current($nodes) === $nodes[$currentNodeId]) {
15
            return $nodes;
16
        }
17
18
        // Move the current node to the first place
19
        $currentNode = $nodes[$currentNodeId];
20
        unset($nodes[$currentNodeId]);
21
        array_unshift($nodes, $currentNode);
22
23
        return $nodes;
24
    }
25
}
26