Passed
Pull Request — master (#9)
by Timon
09:13
created

Cursor::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace TBolier\RethinkQL\Query;
4
5
use TBolier\RethinkQL\Connection\ConnectionInterface;
6
use TBolier\RethinkQL\Response\ResponseInterface;
7
use TBolier\RethinkQL\Types\Response\ResponseType;
8
9
class Cursor implements \Iterator
10
{
11
    /**
12
     * @var ConnectionInterface
13
     */
14
    private $connection;
15
16
    /**
17
     * @var int
18
     */
19
    private $token;
20
21
    /**
22
     * @param ConnectionInterface $connection
23
     * @param int $token
24
     * @param ResponseInterface $response
25
     */
26
    public function __construct(ConnectionInterface $connection, int $token, ResponseInterface $response)
27
    {
28
        $this->connection = $connection;
29
        $this->token = $token;
30
31
        $this->setBatch($response);
32
    }
33
34
    private function setBatch($response)
35
    {
36
        $this->isComplete = $response['t'] === ResponseType::SUCCESS_SEQUENCE;
0 ignored issues
show
Bug introduced by
The property isComplete does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
        $this->currentIndex = 0;
0 ignored issues
show
Bug introduced by
The property currentIndex does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
38
        $this->currentSize = \count($response['r']);
0 ignored issues
show
Bug introduced by
The property currentSize does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
39
        $this->currentData = array();
0 ignored issues
show
Bug introduced by
The property currentData does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
        foreach ($response['r'] as $row) {
41
            $this->currentData[] = $datum = $row;
0 ignored issues
show
Unused Code introduced by
$datum is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
42
        }
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function current()
49
    {
50
        // TODO: Implement current() method.
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function next()
57
    {
58
        // TODO: Implement next() method.
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function key()
65
    {
66
        // TODO: Implement key() method.
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function valid()
73
    {
74
        // TODO: Implement valid() method.
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80
    public function rewind()
81
    {
82
        // TODO: Implement rewind() method.
83
    }
84
}
85