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

MultiResultSet::merge()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
crap 12
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