MultiResultSetAdapter::getNext()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Foolz\SphinxQL\Drivers\Mysqli;
4
5
use Foolz\SphinxQL\Drivers\MultiResultSetAdapterInterface;
6
use Foolz\SphinxQL\Drivers\ResultSet;
7
use Foolz\SphinxQL\Exception\ConnectionException;
8
9
class MultiResultSetAdapter implements MultiResultSetAdapterInterface
10
{
11
    /**
12
     * @var bool
13
     */
14
    protected $valid = true;
15
16
    /**
17
     * @var Connection
18
     */
19
    protected $connection;
20
21
    /**
22
     * @param Connection $connection
23
     */
24
    public function __construct(Connection $connection)
25
    {
26
        $this->connection = $connection;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     * @throws ConnectionException
32
     */
33
    public function getNext()
34
    {
35
        if (
36
            !$this->valid() ||
37
            !$this->connection->getConnection()->more_results()
0 ignored issues
show
Bug introduced by
The method more_results() does not exist on PDO. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            !$this->connection->getConnection()->/** @scrutinizer ignore-call */ more_results()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        ) {
39
            $this->valid = false;
40
        } else {
41
            $this->connection->getConnection()->next_result();
0 ignored issues
show
Bug introduced by
The method next_result() does not exist on PDO. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
            $this->connection->getConnection()->/** @scrutinizer ignore-call */ next_result();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
        }
43
    }
44
45
    /**
46
     * @inheritdoc
47
     * @throws ConnectionException
48
     */
49
    public function current()
50
    {
51
        $adapter = new ResultSetAdapter($this->connection, $this->connection->getConnection()->store_result());
0 ignored issues
show
Bug introduced by
The method store_result() does not exist on PDO. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $adapter = new ResultSetAdapter($this->connection, $this->connection->getConnection()->/** @scrutinizer ignore-call */ store_result());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
        return new ResultSet($adapter);
53
    }
54
55
    /**
56
     * @inheritdoc
57
     * @throws ConnectionException
58
     */
59
    public function valid()
60
    {
61
        return $this->connection->getConnection()->errno == 0 && $this->valid;
0 ignored issues
show
Bug introduced by
The property errno does not seem to exist on PDO.
Loading history...
62
    }
63
}
64