Action::getValue()   A
last analyzed

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
    /**
22
     * @param TAction $action
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...
23
     * @param TKey $key
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
     * @param TValue $value
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...
25
     * @param TTtl $ttl
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...
26
     */
27 154
    private function __construct(
28
        private string $action,
29
        private mixed $key = null,
30
        private mixed $value = null,
31
        private mixed $ttl = null
32
    ) {
33 154
    }
34
35
    /**
36
     * @return TAction
37
     */
38 19
    public function getAction(): string
39
    {
40 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...
41
    }
42
43
    /**
44
     * @return TKey
45
     */
46 20
    public function getKey()
47
    {
48 20
        return $this->key;
49
    }
50
51
    /**
52
     * @return TValue
53
     */
54 5
    public function getValue()
55
    {
56 5
        return $this->value;
57
    }
58
59
    /**
60
     * @return TTtl
61
     */
62 5
    public function getTtl()
63
    {
64 5
        return $this->ttl;
65
    }
66
67 90
    public static function createGetAction(mixed $key): self
68
    {
69 90
        return new self(self::GET, $key);
70
    }
71
72 38
    public static function createHasAction(mixed $key): self
73
    {
74 38
        return new self(self::HAS, $key);
75
    }
76
77 111
    public static function createSetAction(mixed $key, mixed $value, mixed $ttl): self
78
    {
79 111
        return new self(self::SET, $key, $value, $ttl);
80
    }
81
82 33
    public static function createDeleteAction(mixed $key): self
83
    {
84 33
        return new self(self::DELETE, $key);
85
    }
86
87 85
    public static function createClearAction(): self
88
    {
89 85
        return new self(self::CLEAR);
90
    }
91
}
92