Passed
Push — master ( 7c7732...5d308c )
by Stone
03:35
created

Cookie::deleteCookie()   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 Core\Dependency;
4
5
class Cookie{
6
7
    /**
8
     * set a cookie
9
     * @param string $name
10
     * @param string $value
11
     * @param string $expireDate
12
     */
13
    public function setCookie(string $name, string $value, string $expireDate):void
14
    {
15
        setcookie($name, $value, $expireDate, "/");
0 ignored issues
show
Bug introduced by
$expireDate of type string is incompatible with the type integer expected by parameter $expire of setcookie(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        setcookie($name, $value, /** @scrutinizer ignore-type */ $expireDate, "/");
Loading history...
16
    }
17
18
    /**
19
     * delete a named cookie
20
     * @param string $name
21
     */
22
    public function deleteCookie(string $name):void
23
    {
24
        setcookie($name, "", time()-3600); //expire the cookie
25
    }
26
27
    /**
28
     * get a cookie
29
     * @param string $name
30
     * @return mixed
31
     */
32
    public function getCookie(string $name)
33
    {
34
        return $_COOKIE[$name] ?? false;
35
36
    }
37
}