AbstractRepository   A
last analyzed

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
 * @template T of AbstractModel
12
 *
13
 * @extends EntityRepository<T>
14
 *
15
 * @method null|T findOneById(integer $id)
16
 */
17
abstract class AbstractRepository extends EntityRepository
18
{
19
    use \Ecodev\Felix\Repository\Traits\Repository;
20
21
    /**
22
     * Count the total number of objects.
23
     */
24
    public function getCount(): int
25
    {
26
        $connection = $this->getEntityManager()->getConnection();
27
28
        $query = $connection->createQueryBuilder()
29
            ->select('COUNT(*)')
30
            ->from($connection->quoteIdentifier($this->getClassMetadata()->getTableName()));
31
32
        return (int) $query->fetchOne();
33
    }
34
}
35