Passed
Push — master ( a8b983...5b3176 )
by Adrien
10:48
created

AbstractRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCount() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Repository;
6
7
use Application\Model\AbstractModel;
8
use Doctrine\ORM\EntityRepository;
9
10
/**
11
 * Class AbstractRepository
12
 *
13
 * @method null|AbstractModel findOneById(integer $id)
14
 */
15
abstract class AbstractRepository extends EntityRepository
16
{
17
    use \Ecodev\Felix\Repository\Traits\Repository;
18
19
    /**
20
     * Count the total number of objects
21
     */
22
    public function getCount(): int
23
    {
24
        $connection = $this->getEntityManager()->getConnection();
25
26
        $query = $connection->createQueryBuilder()
27
            ->select('COUNT(*)')
28
            ->from($connection->quoteIdentifier($this->getClassMetadata()->getTableName()));
29
30
        return (int) $query->execute()->fetchColumn();
31
    }
32
}
33