Passed
Pull Request — master (#10)
by Korotkov
01:41
created

ContainerCookieTrait::unsetCookie()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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