Passed
Push — main ( 83bea6...22b11c )
by Thierry
01:32
created

Statement::fetchField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver\Fake;
4
5
use Lagdo\DbAdmin\Driver\Db\StatementInterface;
6
use Lagdo\DbAdmin\Driver\Entity\StatementFieldEntity;
7
8
use function count;
9
use function array_values;
10
use function array_pop;
11
12
/**
13
 * Fake Statement class for testing
14
 */
15
class Statement implements StatementInterface
16
{
17
    /**
18
     * The query result
19
     *
20
     * @var array
21
     */
22
    protected $results;
23
24
    /**
25
     * The constructor
26
     *
27
     * @param array $results
28
     */
29
    public function __construct(array $results)
30
    {
31
        $this->results = $results;
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function rows(): array
38
    {
39
        return $this->results;
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function rowCount()
46
    {
47
        return count($this->results);
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53
    public function fetchAssoc()
54
    {
55
        return array_pop($this->results);
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function fetchRow()
62
    {
63
        return array_values(array_pop($this->results));
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69
    public function fetchField()
70
    {
71
        return null;
72
        // return new StatementFieldEntity();
73
    }
74
}
75