Passed
Push — issue#767 ( 0909e2...b3675b )
by Guilherme
05:08
created

ExtremeNotificationsHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A addTransChoice() 0 4 1
A __construct() 0 6 1
A commit() 0 3 1
1
<?php
2
/*
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Helper;
12
13
use Symfony\Component\HttpFoundation\Session\Session;
14
use Symfony\Component\Translation\TranslatorInterface;
15
16
class ExtremeNotificationsHelper
17
{
18
    /** @var Session */
19
    private $session;
20
21
    /** @var TranslatorInterface */
22
    private $translator;
23
24 1
    public function __construct(
25
        Session $session,
26
        TranslatorInterface $translator
27
    ) {
28 1
        $this->session = $session;
29 1
        $this->translator = $translator;
30 1
    }
31
32 1
    public function add($id, $parameters = [])
33
    {
34 1
        $translated = $this->translator->trans($id, $parameters);
35 1
        $this->commit($translated);
36 1
    }
37
38 1
    public function addTransChoice($id, $number, $parameters = [])
39
    {
40 1
        $translated = $this->translator->transChoice($id, $number, $parameters);
41 1
        $this->commit($translated);
42 1
    }
43
44 1
    private function commit($translated)
45
    {
46 1
        $this->session->getFlashBag()->add('alert.unconfirmed.email', $translated);
47 1
    }
48
}
49