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

Action::createClearAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Test\Support\SimpleCache;
6
7
/**
8
 * @template TAction as string
9
 * @template TKey as mixed
10
 * @template TValue as mixed
11
 * @template TTtl as mixed
12
 */
13
final class Action
14
{
15
    public const GET = 'get';
16
    public const SET = 'set';
17
    public const DELETE = 'delete';
18
    public const CLEAR = 'clear';
19
    public const HAS = 'has';
20
21
    /** @var TAction  */
0 ignored issues
show
Bug introduced by
The type Yiisoft\Test\Support\SimpleCache\TAction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
    private string $action;
23
    /** @var TKey */
0 ignored issues
show
Bug introduced by
The type Yiisoft\Test\Support\SimpleCache\TKey was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
    private $key;
25
    /** @var TValue */
0 ignored issues
show
Bug introduced by
The type Yiisoft\Test\Support\SimpleCache\TValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
    private $value;
27
    /** @var TTtl */
0 ignored issues
show
Bug introduced by
The type Yiisoft\Test\Support\SimpleCache\TTtl was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
    private $ttl;
29
30
    /**
31
     * @param TAction $action
32
     * @param TKey $key
33
     * @param TValue $value
34
     * @param TTtl $ttl
35
     */
36 90
    private function __construct(string $action, $key = null, $value = null, $ttl = null)
37
    {
38 90
        $this->action = $action;
0 ignored issues
show
Documentation Bug introduced by
It seems like $action of type string is incompatible with the declared type Yiisoft\Test\Support\SimpleCache\TAction of property $action.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
39 90
        $this->key = $key;
40 90
        $this->value = $value;
41 90
        $this->ttl = $ttl;
42 90
    }
43
44
    /**
45
     * @return TAction
46
     */
47
    public function getAction(): string
48
    {
49
        return $this->action;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->action returns the type string which is incompatible with the documented return type Yiisoft\Test\Support\SimpleCache\TAction.
Loading history...
50
    }
51
52
    /**
53
     * @return TKey
54
     */
55
    public function getKey()
56
    {
57
        return $this->key;
58
    }
59
60
    /**
61
     * @return TValue
62
     */
63
    public function getValue()
64
    {
65
        return $this->value;
66
    }
67
68
    /**
69
     * @param mixed $key
70
     */
71 73
    public static function createGetAction($key): self
72
    {
73 73
        return new self(self::GET, $key);
74
    }
75
76
    /**
77
     * @param mixed $key
78
     */
79 14
    public static function createHasAction($key): self
80
    {
81 14
        return new self(self::HAS, $key);
82
    }
83
84
    /**
85
     * @param mixed $key
86
     * @param mixed $value
87
     * @param mixed $ttl
88
     */
89 83
    public static function createSetAction($key, $value, $ttl): self
90
    {
91 83
        return new self(self::SET, $key, $value, $ttl);
92
    }
93
94
    /**
95
     * @param mixed $key
96
     * @param mixed $value
97
     * @param mixed $ttl
98
     */
99
    public static function createSetMultipleAction($key, $value, $ttl): self
100
    {
101
        return new self(self::SET, $key, $value, $ttl);
102
    }
103
104
    /**
105
     * @param mixed $key
106
     */
107 15
    public static function createDeleteAction($key): self
108
    {
109 15
        return new self(self::DELETE, $key);
110
    }
111
112 83
    public static function createClearAction(): self
113
    {
114 83
        return new self(self::CLEAR);
115
    }
116
}
117