Passed
Pull Request — master (#16)
by Aleksei
02:40
created

Action::createSetMultipleAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Test\Support\SimpleCache;
6
7
final class Action
8
{
9
    public const GET = 'get';
10
    public const SET = 'set';
11
    public const DELETE = 'delete';
12
    public const CLEAR = 'clear';
13
    public const HAS = 'has';
14
15
    private string $action;
16
    /** @var mixed */
17
    private $key;
18
    /** @var mixed */
19
    private $value;
20
    /** @var mixed */
21
    private $ttl;
22
23
    /**
24
     * @param string $action
25
     * @param mixed $key
26
     * @param mixed $value
27
     * @param mixed $ttl
28
     */
29 90
    private function __construct(string $action, $key = null, $value = null, $ttl = null)
30
    {
31 90
        $this->action = $action;
32 90
        $this->key = $key;
33 90
        $this->value = $value;
34 90
        $this->ttl = $ttl;
35 90
    }
36
37
    public function getAction(): string
38
    {
39
        return $this->action;
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    public function getKey()
46
    {
47
        return $this->key;
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    public function getValue()
54
    {
55
        return $this->value;
56
    }
57
58
    /**
59
     * @param mixed $key
60
     */
61 73
    public static function createGetAction($key): self
62
    {
63 73
        return new self(self::GET, $key);
64
    }
65
66
    /**
67
     * @param mixed $key
68
     */
69 14
    public static function createHasAction($key): self
70
    {
71 14
        return new self(self::HAS, $key);
72
    }
73
74
    /**
75
     * @param mixed $key
76
     * @param mixed $value
77
     * @param mixed $ttl
78
     */
79 83
    public static function createSetAction($key, $value, $ttl): self
80
    {
81 83
        return new self(self::SET, $key, $value, $ttl);
82
    }
83
84
    /**
85
     * @param mixed $key
86
     * @param mixed $value
87
     * @param mixed $ttl
88
     */
89
    public static function createSetMultipleAction($key, $value, $ttl): self
90
    {
91
        return new self(self::SET, $key, $value, $ttl);
92
    }
93
94
    /**
95
     * @param mixed $key
96
     */
97 15
    public static function createDeleteAction($key): self
98
    {
99 15
        return new self(self::DELETE, $key);
100
    }
101
102 83
    public static function createClearAction(): self
103
    {
104 83
        return new self(self::CLEAR);
105
    }
106
}
107