Completed
Push — master ( 47bc51...5c6509 )
by Igor
02:23
created

Alert   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 1
cbo 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A alert() 0 8 2
1
<?php
2
/**
3
 * @license MIT
4
 * @author Igor Sorokin <[email protected]>
5
 */
6
namespace Dspbee\Bundle\Alert;
7
8
/**
9
 * Save message to the cookie.
10
 *
11
 * Class Alert
12
 * @package Dspbee\Bundle\Alert
13
 */
14
abstract class Alert
15
{
16
    public function __construct()
17
    {
18
        $this->color = 'green';
19
    }
20
21
    /**
22
     * @param string $message
23
     *
24
     * @return bool
25
     */
26
    public function alert($message)
27
    {
28
        if (!headers_sent()) {
29
            setcookie('__alert__', $message . '|' . $this->color, time() + 3600 * 24 * 30, '/');
30
            return true;
31
        }
32
        return false;
33
    }
34
35
    protected $color;
36
}