Passed
Pull Request — master (#576)
by Alexander
05:20 queued 02:59
created

CacheCollector::getView()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Debug\CacheCollector;
6
7
use DateInterval;
8
use Yiisoft\Yii\Debug\Api\HtmlViewProviderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\Debug\Api\HtmlViewProviderInterface 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...
9
use Yiisoft\Yii\Debug\Api\ModuleFederationProviderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\Debug\Api\Mo...rationProviderInterface 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...
10
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\Debug\Collector\CollectorTrait 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...
11
12
class CacheCollector implements HtmlViewProviderInterface, ModuleFederationProviderInterface
13
{
14
    use CollectorTrait;
15
16
    public array $set = [];
17
    private array $get = [];
18
19
    public function collectGet(string $key): void
20
    {
21
        $this->get[$key] = $key;
22
    }
23
24
    public function collectSet(string $key, mixed $value, DateInterval|int|null $ttl)
25
    {
26
        $this->set[$key] = [
27
            'key' => $key,
28
            'value' => $value,
29
            'ttl' => $ttl,
30
        ];
31
    }
32
33
    public function getCollected(): array
34
    {
35
        return [
36
            'cache' => [
37
                'get' => array_values($this->get),
38
                'set' => array_values($this->set),
39
            ],
40
        ];
41
    }
42
43
    public function getIndexData(): array
44
    {
45
        return [
46
            'cache' => [
47
                'get' => [
48
                    'total' => array_values($this->get),
49
                ],
50
                'set' => [
51
                    'total' => array_values($this->set),
52
                ],
53
            ],
54
        ];
55
    }
56
57
    public static function getView(): string
58
    {
59
        return '@views/debug/index';
60
    }
61
62
    public static function getAsset(): CacheCollectorAsset
63
    {
64
        return new CacheCollectorAsset();
65
    }
66
}
67