Passed
Push — master ( db039c...4d8c20 )
by Dāvis
04:33
created

AlertReport::addWarning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Script\Model;
4
5
class AlertReport implements AlertReporterInterface
6
{
7
    private $alertManager;
8
9
    public function __construct(AlertManagerInterface $alertManager)
10
    {
11
        $this->alertManager = $alertManager;
12
    }
13
14
    public function addError($message)
15
    {
16
        $this->add(AlertInterface::ERROR, $message);
17
    }
18
19
    public function addSuccess($message)
20
    {
21
        $this->add(AlertInterface::SUCCESS, $message);
22
    }
23
24
    public function addInfo($message)
25
    {
26
        $this->add(AlertInterface::INFO, $message);
27
    }
28
29
    public function addWarning($message)
30
    {
31
        $this->add(AlertInterface::WARNING, $message);
32
    }
33
34
    public function add($type = 'info', $message)
35
    {
36
        if (!\in_array($type, AlertManager::getAlertTypes(), true)) {
37
            $type = 'info';
38
        }
39
        $this->alertManager->addAlert(new Alert($type, $message));
40
    }
41
}
42