1 | <?php |
||
16 | class DBALStorage extends AbstractStorage { |
||
17 | |||
18 | protected $connection; |
||
19 | |||
20 | protected $table; |
||
21 | |||
22 | protected $statementKeyExists; |
||
23 | |||
24 | protected $statementKeyInsert; |
||
25 | |||
26 | protected $statementKeyUpdate; |
||
27 | |||
28 | protected function buildStatements() { |
||
29 | $queryBuilder = $this->connection->createQueryBuilder() |
||
|
|||
30 | ->select('COUNT(`key`) AS amount') |
||
31 | ->from('`'.$this->table.'`') |
||
32 | ->where('`key` = ?') |
||
33 | ; |
||
34 | $this->statementKeyExists = $this->connection->prepare($queryBuilder->getSQL()); |
||
35 | |||
36 | $queryBuilder = $this->connection->createQueryBuilder() |
||
37 | ->insert('`'.$this->table.'`') |
||
38 | ->setValue('`value`', '?') |
||
39 | ->setValue('`key`', '?') |
||
40 | ; |
||
41 | $this->statementKeyInsert = $this->connection->prepare($queryBuilder->getSQL()); |
||
42 | |||
43 | $queryBuilder = $this->connection->createQueryBuilder() |
||
44 | ->update('`'.$this->table.'`') |
||
45 | ->set('`value`', '?') |
||
46 | ->where('`key` = ?') |
||
47 | ; |
||
48 | $this->statementKeyUpdate = $this->connection->prepare($queryBuilder->getSQL()); |
||
49 | } |
||
50 | |||
51 | public function __construct(Connection $connection, $table = 'phpprom') { |
||
52 | $this->connection = $connection; |
||
53 | $this->table = $table; |
||
54 | $this->buildStatements(); |
||
55 | } |
||
56 | |||
57 | public function storeMeasurement($prefix, $key, $value) { |
||
67 | |||
68 | public function getMeasurements($prefix, array $keys) { |
||
90 | } |
||
91 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.