CityRepository::countAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Repository;
6
7
use App\Entity\City;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Doctrine\Persistence\ManagerRegistry;
10
11
/**
12
 * @method city|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method city|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method city[]    findAll()
15
 * @method city[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16
 */
17
final class CityRepository extends ServiceEntityRepository
18
{
19
    public function __construct(ManagerRegistry $registry)
20
    {
21
        parent::__construct($registry, City::class);
22
    }
23
24
    public function countAll(): int
25
    {
26
        $count = $this->createQueryBuilder('l')
27
            ->select('count(l.id)')
28
            ->getQuery()
29
            ->getSingleScalarResult();
30
31
        return (int) $count;
32
    }
33
}
34