AskQueryHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 26
ccs 15
cts 15
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A runQuery() 0 7 1
A getFinalQueryResult() 0 6 3
A buildResultVars() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-2 license.
6
 *
7
 * (c) Konrad Abicht <[email protected]>
8
 * (c) Benjamin Nowack
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace sweetrdf\InMemoryStoreSqlite\Store\QueryHandler;
15
16
class AskQueryHandler extends SelectQueryHandler
17
{
18 3
    public function runQuery($infos)
19
    {
20 3
        $infos['query']['limit'] = 1;
21 3
        $this->infos = $infos;
22 3
        $this->buildResultVars();
23
24 3
        return parent::runQuery($this->infos);
25
    }
26
27 3
    private function buildResultVars()
28
    {
29 3
        $this->infos['query']['result_vars'][] = [
30 3
            'var' => '1',
31 3
            'aggregate' => '',
32 3
            'alias' => 'success',
33 3
        ];
34
    }
35
36 3
    protected function getFinalQueryResult($q_sql, $tmp_tbl)
37
    {
38 3
        $row = $this->store->getDBObject()->fetchRow('SELECT success FROM '.$tmp_tbl);
39 3
        $r = isset($row['success']) ? $row['success'] : 0;
40
41 3
        return $r ? true : false;
42
    }
43
}
44