ActiveQuery::count()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Libraries.io API implementation for yii2-hiart.
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart-librariesio
6
 * @package   yii2-hiart-librariesio
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\librariesio;
12
13
/**
14
 * Libraries.io API implementation.
15
 *
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class ActiveQuery extends \hiqdev\hiart\ActiveQuery
19
{
20 1
    public function count($q = '*', $db = null)
21
    {
22 1
        $this->count = $q;
23
24 1
        $response = $this->limit(1)->searchBatch($db);
25 1
        $totals = $response->getHeader('total');
26
27 1
        return reset($totals);
28
    }
29
}
30