Completed
Push — master ( d6fc27...dc9f7f )
by Hung
19s
created

MultiResultSetAdapter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getNext() 0 9 3
A current() 0 4 1
A valid() 0 4 2
1
<?php
2
3
namespace Foolz\SphinxQL\Drivers\Pdo;
4
5
class MultiResultSetAdapter implements \Foolz\SphinxQL\Drivers\MultiResultSetAdapterInterface
6
{
7
    /**
8
     * @var bool
9
     */
10
    protected $valid = true;
11
12
    /**
13
     * @var \PDOStatement
14
     */
15
    protected $statement = null;
16
17
    public function __construct($statement)
18
    {
19
        $this->statement = $statement;
20
    }
21
22
    public function getNext()
23
    {
24
        if (
25
            !$this->valid() ||
26
            !$this->statement->nextRowset()
27
        ) {
28
            $this->valid = false;
29
        }
30
    }
31
32
    /**
33
     * @return ResultSet
34
     */
35
    public function current()
36
    {
37
        return ResultSet::make($this->statement);
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function valid()
44
    {
45
        return $this->statement && $this->valid;
46
    }
47
}
48