Completed
Push — master ( 0ac7b2...c19566 )
by Alex
07:31
created

PdoCrudMock::unlock()   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
namespace Mezon\PdoCrud\Tests;
3
4
class PdoCrudMock extends \Mezon\PdoCrud\PdoCrud
5
{
6
7
    public $selectResult = [];
8
9
    /**
10
     * Getting records
11
     *
12
     * @param string $fields
13
     *            List of fields
14
     * @param string $tableNames
15
     *            List of tables
16
     * @param string $where
17
     *            Condition
18
     * @param int $from
19
     *            First record in query
20
     * @param int $limit
21
     *            Count of records
22
     * @return array List of records
23
     */
24
    public function select(
25
        string $fields,
26
        string $tableNames,
27
        string $where = '1 = 1',
28
        int $from = 0,
29
        int $limit = 1000000): array
30
    {
31
        return $this->selectResult;
32
    }
33
34
    /**
35
     * Counter for update method calls
36
     *
37
     * @var integer
38
     */
39
    public $updateWasCalledCounter = 0;
40
41
    /**
42
     * Updating records
43
     *
44
     * @param string $tableName
45
     *            Table name
46
     * @param array $record
47
     *            Updating records
48
     * @param string $where
49
     *            Condition
50
     * @param int $limit
51
     *            Liti for afffecting records
52
     * @return int Count of updated records
53
     */
54
    public function update(string $tableName, array $record, string $where, int $limit = 10000000): int
55
    {
56
        $this->updateWasCalledCounter ++;
57
58
        return 1;
59
    }
60
61
    /**
62
     * Counter for delete method calls
63
     *
64
     * @var integer
65
     */
66
    public $deleteWasCalledCounter = 0;
67
68
    /**
69
     * Deleting records
70
     *
71
     * @param string $tableName
72
     *            Table name
73
     * @param string $where
74
     *            Condition
75
     * @param int $limit
76
     *            Liti for afffecting records
77
     * @return int Count of deleted records
78
     */
79
    public function delete($tableName, $where, $limit = 10000000): int
80
    {
81
        $this->deleteWasCalledCounter ++;
82
83
        return 1;
84
    }
85
86
    /**
87
     * Locked tables
88
     * 
89
     * @var array
90
     */
91
    public $lockedTables = [];
92
93
    /**
94
     * Locked tables modes
95
     *
96
     * @var array
97
     */
98
    public $lockedTablesModes = [];
99
100
    /**
101
     * Method locks tables
102
     *
103
     * @param array $tables
104
     *            List of tables
105
     * @param array $modes
106
     *            List of lock modes
107
     */
108
    public function lock(array $tables, array $modes): void
109
    {
110
        $this->lockedTables = $tables;
111
        $this->lockedTablesModes = $modes;
112
    }
113
114
    /**
115
     * Method unlocks locked tables
116
     */
117
    public function unlock(): void
118
    {
119
        $this->lockedTables = $this->lockedTablesModes = [];
120
    }
121
}
122