Passed
Push — master ( 8b441d...0083f3 )
by Andreas
17:38
created

org_openpsa_qbpager_direct   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 26
ccs 6
cts 10
cp 0.6
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute_unchecked() 0 3 1
A _prepare_qbs() 0 5 1
A count_unchecked() 0 6 2
1
<?php
2
/**
3
 * @package org.openpsa.qbpager
4
 */
5
/**
6
 * Pages QB resultsets (uses midgard QB directly)
7
 *
8
 * @package org.openpsa.qbpager
9
 */
10
class org_openpsa_qbpager_direct extends org_openpsa_qbpager
11
{
12 1
    protected function _prepare_qbs(string $classname)
13
    {
14 1
        $this->_midcom_qb = new midgard_query_builder($classname);
15
        // Make another QB for counting, we need to do this to avoid trouble with core internal references system
16 1
        $this->_midcom_qb_count = new midgard_query_builder($classname);
17 1
    }
18
19
    /**
20
     * Wraps to execute since this is what midcom QB does, too
21
     */
22 1
    public function execute_unchecked() : array
23
    {
24 1
        return $this->execute();
25
    }
26
27
    /**
28
     * Wraps to count since this is what midcom QB does, too
29
     */
30
    public function count_unchecked() : int
31
    {
32
        if (!$this->count) {
33
            $this->count = $this->_midcom_qb_count->count();
34
        }
35
        return $this->count;
36
    }
37
}
38