CategoryRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

2 Methods

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