AlertReporter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 64
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addError() 0 6 1
A addSuccess() 0 6 1
A addInfo() 0 6 1
A addWarning() 0 6 1
1
<?php
2
/**
3
 * AlertReporter.php
4
 * Definition of class AlertReporter
5
 *
6
 * Created 28/08/14 23:58
7
 *
8
 * @author Rasanga Perera <[email protected]>
9
 * Copyright (c) 2014, The MIT License (MIT)
10
 */
11
12
namespace Ras\Bundle\FlashAlertBundle\Model;
13
14
15
class AlertReporter
16
{
17
    /**
18
     * @var AlertManagerInterface
19
     */
20
    private $alertManager;
21
22
23
    /**
24
     * @param AlertManagerInterface $alertManager
25
     */
26
    public function __construct(AlertManagerInterface $alertManager)
27
    {
28
        $this->alertManager = $alertManager;
29
    }
30
31
    /**
32
     * Adds error alert to session flash bag
33
     *
34
     * @param string $message
35
     */
36
    public function addError($message)
37
    {
38
        $this->alertManager->addAlert(
39
            new Alert(AlertInterface::ERROR_ALERT, $message)
40
        );
41
    }
42
43
    /**
44
     * Adds success alert to session flash bag
45
     *
46
     * @param string $message
47
     */
48
    public function addSuccess($message)
49
    {
50
        $this->alertManager->addAlert(
51
            new Alert(AlertInterface::SUCCESS_ALERT, $message)
52
        );
53
    }
54
55
    /**
56
     * Adds information alert to session flash bag
57
     *
58
     * @param string $message
59
     */
60
    public function addInfo($message)
61
    {
62
        $this->alertManager->addAlert(
63
            new Alert(AlertInterface::INFO_ALERT, $message)
64
        );
65
    }
66
67
    /**
68
     * Adds warning (block) alert to session flash bag
69
     *
70
     * @param string $message
71
     */
72
    public function addWarning($message)
73
    {
74
        $this->alertManager->addAlert(
75
            new Alert(AlertInterface::WARNING_ALERT, $message)
76
        );
77
    }
78
}