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

ResultSet   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 44.44%

Importance

Changes 8
Bugs 1 Features 2
Metric Value
wmc 7
c 8
b 1
f 2
lcom 2
cbo 2
dl 0
loc 40
ccs 8
cts 18
cp 0.4444
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getSingleRow() 0 8 2
A getMeta() 0 4 1
A getAllowedCount() 0 4 1
A getTotalCount() 0 4 1
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