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

AccountRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 34
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A getAccountsCount() 0 7 1
A getLinkedAccountsCount() 0 8 1
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
}