DoctrineQuery::__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 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
nc 1
cc 1
eloc 2
nop 1
crap 1
1
<?php
2
3
namespace Nayjest\Querying;
4
5
use Doctrine\DBAL\Query\QueryBuilder;
6
use Exception;
7
use Nayjest\Querying\Handler\Doctrine\Factory;
8
use Nayjest\Querying\Row\ObjectRow;
9
10
class DoctrineQuery extends AbstractDatabaseQuery
11
{
12 3
    public function __construct(QueryBuilder $dataSource)
13
    {
14 3
        parent::__construct($dataSource, ObjectRow::class);
15 3
    }
16
17
    /**
18
     * @return QueryBuilder
19
     * @throws Exception
20
     */
21 2
    public function getDoctrineQuery()
22
    {
23 2
        return $this->getReadyQuery();
24
    }
25
    /**
26
     * @return string
27
     * @throws Exception
28
     */
29 1
    public function getSQL()
30 1
    {
31 1
        return $this->getDoctrineQuery()->getSQL();
32
    }
33
34
    /**
35
     * @return int
36
     */
37 1
    protected function getCountInternal()
38
    {
39 1
        return (int)$this
40 1
            ->getDoctrineQuery()
41 1
            ->select('count(*) as row_count')
42 1
            ->execute()
43 1
            ->fetchColumn();
44
    }
45
46 3
    protected function getHandlerFactory()
47
    {
48 3
        return new Factory();
49
    }
50
}
51