Completed
Push — master ( 97dfc1...bb1c5d )
by Konstantin
14:18
created

MultiResultSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 33.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 21
ccs 4
cts 12
cp 0.3333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A merge() 0 11 3
1
<?php
2
3
namespace Brouzie\Sphinxy\Query;
4
5
/**
6
 * @method SimpleResultSet[] getIterator()
7
 */
8
class MultiResultSet extends ResultSet
9
{
10
    public function __construct(array $result, array $rawMeta)
11
    {
12 3
        parent::__construct(array_map(function($result) {
13 3
            return new SimpleResultSet($result);
14 3
        }, $result), $rawMeta);
15 3
    }
16
17
    public function merge(self $multiResultSet)
18
    {
19
        foreach ($multiResultSet as $name => $resultSet) {
20
            if (is_string($name)) {
21
                $this->result[$name] = $resultSet;
22
                //TODO: save meta
23
            } else {
24
                $this->result[] = $resultSet;
25
            }
26
        }
27
    }
28
}
29