RefactorPriorityQuery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Hgraca\Phorensic\Analyser\Query;
4
5
use Hgraca\Phorensic\SharedKernel\Port\Database\DatabaseClientInterface;
6
7
final class RefactorPriorityQuery
8
{
9
    /** @var DatabaseClientInterface */
10
    private $dbClient;
11
12
    /** @var string */
13
    const SQL = "
14
        SELECT `path`, `type`, `commits`, `wmc`, (`commits` * `wmc`) as `refactor_priority`
15
        FROM `files`
16
        WHERE `type` = 'php'
17
        ORDER BY `refactor_priority` DESC
18
    ";
19
20 2
    public function __construct(DatabaseClientInterface $dbClient)
21
    {
22 2
        $this->dbClient = $dbClient;
23 2
    }
24
25
    /**
26
     * @return array [[path, commits, wmc, refactor_priority], ...]
27
     */
28 2
    public function execute(int $limit = null): array
29
    {
30 2
        $sql = $limit === null ? self::SQL : self::SQL . " LIMIT $limit";
31
32 2
        return $this->dbClient->executeQuery($sql);
33
    }
34
}
35