CookieValue::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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 7
    public function __construct(?string $value = null)
19
    {
20 7
        $this->value = $value;
21
    }
22
23
    /**
24
     * @inheritDoc
25
     */
26 7
    public function get(): ?string
27
    {
28 7
        return $this->value;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 2
    public function set(string $value, int $expire): void
35
    {
36 2
        $this->value = $value;
37 2
        $this->expire = $expire;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43 1
    public function clear(): void
44
    {
45 1
        $this->value = null;
46 1
        $this->expire = 1;
47
    }
48
49
    /**
50
     * Get expire time for the cookie.
51
     */
52 3
    public function getExpire(): int
53
    {
54 3
        return $this->expire;
55
    }
56
}
57