Passed
Push — master ( 0083f3...057072 )
by Andreas
17:57
created

org_openpsa_qbpager_direct   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 18
ccs 4
cts 8
cp 0.5
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
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 count since this is what midcom QB does, too
21
     */
22
    public function count_unchecked() : int
23
    {
24
        if (!$this->count) {
25
            $this->count = $this->_midcom_qb_count->count();
26
        }
27
        return $this->count;
28
    }
29
}
30