Test Setup Failed
Push — master ( 72a408...3f5e9b )
by Alexey
02:46
created

AccountRepository::getLinkedAccountsCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Repository\Telegram;
4
5
use Doctrine\ORM\EntityRepository;
6
use Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account;
7
8
class AccountRepository extends EntityRepository
9
{
10
    public function add(Account $entity): void
11
    {
12
        $this->getEntityManager()->persist($entity);
13
    }
14
15
    /**
16
     * Returns total number of accounts
17
     *
18
     * @return int
19
     */
20
    public function getAccountsCount(): int
21
    {
22
        return $this->createQueryBuilder('a')
23
            ->select('COUNT(a)')
24
            ->getQuery()->getSingleScalarResult()
25
        ;
26
    }
27
28
    /**
29
     * Returns number of accounts with linked Point.im profile
30
     *
31
     * @return int
32
     */
33
    public function getLinkedAccountsCount(): int
34
    {
35
        return $this->createQueryBuilder('a')
36
            ->select('COUNT(a)')
37
            ->where('a.user IS NOT NULL')
38
            ->getQuery()->getSingleScalarResult()
39
        ;
40
    }
41
}