Passed
Pull Request — master (#16)
by Aleksei
11:52
created

Action::getAction()   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 158
    private function __construct(string $action, $key = null, $value = null, $ttl = null)
37
    {
38 158
        $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 158
        $this->key = $key;
40 158
        $this->value = $value;
41 158
        $this->ttl = $ttl;
42 158
    }
43
44
    /**
45
     * @return TAction
46
     */
47 19
    public function getAction(): string
48
    {
49 19
        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 20
    public function getKey()
56
    {
57 20
        return $this->key;
58
    }
59
60
    /**
61
     * @return TValue
62
     */
63 5
    public function getValue()
64
    {
65 5
        return $this->value;
66
    }
67
68
    /**
69
     * @return TTtl
70
     */
71 5
    public function getTtl()
72
    {
73 5
        return $this->ttl;
74
    }
75
76
    /**
77
     * @param mixed $key
78
     */
79 91
    public static function createGetAction($key): self
80
    {
81 91
        return new self(self::GET, $key);
82
    }
83
84
    /**
85
     * @param mixed $key
86
     */
87 39
    public static function createHasAction($key): self
88
    {
89 39
        return new self(self::HAS, $key);
90
    }
91
92
    /**
93
     * @param mixed $key
94
     * @param mixed $value
95
     * @param mixed $ttl
96
     */
97 112
    public static function createSetAction($key, $value, $ttl): self
98
    {
99 112
        return new self(self::SET, $key, $value, $ttl);
100
    }
101
102
    /**
103
     * @param mixed $key
104
     */
105 34
    public static function createDeleteAction($key): self
106
    {
107 34
        return new self(self::DELETE, $key);
108
    }
109
110 85
    public static function createClearAction(): self
111
    {
112 85
        return new self(self::CLEAR);
113
    }
114
}
115