Completed
Push — master ( 7fd4a2...4773f0 )
by Konstantin
14:28 queued 09:30
created

ResultSet::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 11
ccs 7
cts 8
cp 0.875
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
crap 2.0078
1
<?php
2
3
namespace Brouzie\Sphinxy\Query;
4
5
use Brouzie\Sphinxy\Exception\NonUniqueResultException;
6
7
class ResultSet extends SimpleResultSet
8
{
9
    protected $meta;
10
11 3
    public function __construct(array $result, array $rawMeta)
12
    {
13 1
        parent::__construct($result);
14
15 3
        $meta = array();
16 1
        foreach ($rawMeta as $row) {
17 1
            $meta[$row['Variable_name']] = $row['Value'];
18
        }
19
20 3
        $this->meta = $meta;
21 1
    }
22
23
    public function getSingleRow()
24
    {
25
        if (count($this->result) > 1) {
26
            throw new NonUniqueResultException();
27
        }
28
29
        return $this->result[0];
30
    }
31
32
    public function getMeta()
33
    {
34
        return $this->meta;
35
    }
36
37
    public function getAllowedCount()
38
    {
39
        return (int) $this->meta['total'];
40
    }
41
42
    public function getTotalCount()
43
    {
44
        return (int) $this->meta['total_found'];
45
    }
46
}
47