Completed
Push — master ( 3c5e5f...6e3c38 )
by Korotkov
02:32
created

ContainerCookieTrait::setCookie()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Date: 06.04.17
7
 * Time: 14:55
8
 *
9
 * @author    : Korotkov Danila <[email protected]>
10
 * @copyright Copyright (c) 2016, Korotkov Danila
11
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
12
 */
13
14
namespace Rudra;
15
16
/**
17
 * Class ContainerCookieTrait
18
 *
19
 * @package Rudra
20
 */
21
trait ContainerCookieTrait
22
{
23
24
    /**
25
     * @param string $key
26
     *
27
     * @return string
28
     */
29
    public function getCookie(string $key): string
30
    {
31
        return $_COOKIE[$key];
32
    }
33
34
    /**
35
     * @param string $key
36
     *
37
     * @return bool
38
     */
39
    public function hasCookie(string $key): bool
40
    {
41
        return isset($_COOKIE[$key]);
42
    }
43
44
    /**
45
     * @codeCoverageIgnore
46
     *
47
     * @param string $key
48
     */
49
    public function unsetCookie(string $key): void
50
    {
51
        unset($_COOKIE[$key]);
52
        setcookie($key, null, -1, '/');
53
    }
54
55
    /**
56
     * @param string $key
57
     * @param string $value
58
     */
59
    public function setCookie(string $key, string $value): void
60
    {
61
        $_COOKIE[$key] = $value;
62
    }
63
}