Completed
Push — master ( 6a706e...7fd4a2 )
by Konstantin
12:25
created

ResultSet::getSingleRow()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 6
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 3
        parent::__construct($result);
14
15 3
        $meta = array();
16 3
        foreach ($rawMeta as $row) {
17 3
            $meta[$row['Variable_name']] = $row['Value'];
18 3
        }
19
20 3
        $this->meta = $meta;
21 3
    }
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