Passed
Push — master ( c0d33c...41aaf7 )
by Arnold
15:34 queued 05:37
created

CookieValue::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Auth\Session\Jwt;
6
7
/**
8
 * Temporary store of the JWT cookie.
9
 */
10
class CookieValue implements CookieInterface
11
{
12
    protected ?string $value;
13
    protected int $expire = 0;
14
15
    /**
16
     * Cookies constructor.
17
     */
18
    public function __construct(?string $value = null)
19
    {
20
        $this->value = $value;
21
    }
22
23
    /**
24
     * @inheritDoc
25
     */
26
    public function get(): ?string
27
    {
28
        return $this->value;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function set(string $value, int $expire): void
35
    {
36
        $this->value = $value;
37
        $this->expire = $expire;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function clear(): void
44
    {
45
        $this->value = null;
46
        $this->expire = 1;
47
    }
48
49
    /**
50
     * Get expire time for the cookie.
51
     */
52
    public function getExpire(): int
53
    {
54
        return $this->expire;
55
    }
56
}
57