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

Alert::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}