|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NV\RequestLimitBundle\Storage\Provider; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
class MySQLProvider implements ProviderInterface |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var EntityManager $_em |
|
11
|
|
|
*/ |
|
12
|
|
|
private $_em; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param EntityManager $em |
|
16
|
|
|
*/ |
|
17
|
|
|
public function __construct($em) |
|
18
|
|
|
{ |
|
19
|
|
|
$this->_em = $em; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param $configuration |
|
24
|
|
|
*/ |
|
25
|
|
|
public function configure($configuration) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @inheritdoc |
|
31
|
|
|
*/ |
|
32
|
|
|
public function get($key) |
|
33
|
|
|
{ |
|
34
|
|
|
$connection = $this->_em->getConnection(); |
|
35
|
|
|
$statement = $connection->exec( |
|
36
|
|
|
'SELECT expires_at FROM nv_request_limit_items |
|
37
|
|
|
WHERE item_key = :item_key' |
|
38
|
|
|
); |
|
39
|
|
|
$statement->bindParam('item_key', $key); |
|
40
|
|
|
$result = $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
41
|
|
|
$connection->close(); |
|
42
|
|
|
|
|
43
|
|
|
return $result; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @inheritdoc |
|
48
|
|
|
*/ |
|
49
|
|
View Code Duplication |
public function set($key, $expiresAt) |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
$connection = $this->_em->getConnection(); |
|
52
|
|
|
$statement = $connection->exec( |
|
53
|
|
|
'INSERT INTO nv_request_limit_items (item_key, expires_at) VALUES item_key = :item_key, expires_at = :expires_at' |
|
54
|
|
|
); |
|
55
|
|
|
$statement->bindParam('item_key', $key); |
|
56
|
|
|
$statement->bindParam('expires_at', $key); |
|
57
|
|
|
$connection->close(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @inheritdoc |
|
62
|
|
|
*/ |
|
63
|
|
View Code Duplication |
public function remove($key) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$connection = $this->_em->getConnection(); |
|
66
|
|
|
$statement = $connection->exec('DELETE FROM nv_request_limit_items WHERE item_key = :item_key'); |
|
67
|
|
|
$statement->bindParam('item_key', $key); |
|
68
|
|
|
$connection->close(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return array |
|
73
|
|
|
*/ |
|
74
|
|
|
public function fetchAllItems() |
|
75
|
|
|
{ |
|
76
|
|
|
$connection = $this->_em->getConnection(); |
|
77
|
|
|
$result = $connection->executeQuery('SELECT * FROM nv_request_limit_items')->fetchAll(); |
|
78
|
|
|
$connection->close(); |
|
79
|
|
|
|
|
80
|
|
|
return $result; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return int |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getItemsCount() |
|
87
|
|
|
{ |
|
88
|
|
|
$connection = $this->_em->getConnection(); |
|
89
|
|
|
$result = $connection->executeQuery('SELECT COUNT(*) FROM nv_request_limit_items')->fetchColumn(0); |
|
90
|
|
|
$connection->close(); |
|
91
|
|
|
|
|
92
|
|
|
return $result; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths