Passed
Push — master ( 6c1980...4e24b5 )
by Alexey
03:34
created

Notifier   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 42
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A sendUsersRenamedNotification() 0 6 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Service\Telegram;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\EntityRepository;
7
use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
8
9
/**
10
 * Notifies Telegram users about some events
11
 */
12
class Notifier
13
{
14
    /**
15
     * @var EntityManagerInterface
16
     */
17
    private $em;
18
19
    /**
20
     * @var EntityRepository
21
     */
22
    private $accountsRepo;
23
24
    /**
25
     * @var MessageSender
26
     */
27
    private $messenger;
28
29
30
    /**
31
     * Notifier constructor.
32
     *
33
     * @param EntityManagerInterface $em
34
     * @param MessageSender $messenger
35
     */
36
    public function __construct(EntityManagerInterface $em, MessageSender $messenger)
37
    {
38
        $this->em = $em;
39
        $this->messenger = $messenger;
40
41
        $this->accountsRepo = $em->getRepository('SkobkinPointToolsBundle:Telegram\Account');
42
    }
43
44
    /**
45
     * @param UserRenameEvent[] $userRenameEvents
46
     */
47
    public function sendUsersRenamedNotification(array $userRenameEvents)
48
    {
49
        $accounts = $this->accountsRepo->findBy(['renameNotification' => true]);
50
51
        $this->messenger->sendMassTemplatedMessage($accounts, '@SkobkinPointTools/Telegram/users_renamed_notification.md.twig', ['events' => $userRenameEvents]);
52
    }
53
}