Passed
Push — trunk ( d20c2d...007cde )
by Christian
10:17 queued 12s
created

HttpCache   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 89
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setMaxAge() 0 8 1
A setStates() 0 8 1
A getMaxAge() 0 8 1
A getStates() 0 8 1
A allowArray() 0 8 1
A getAliasName() 0 8 1
A __construct() 0 9 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Framework\Cache\Annotation;
4
5
use Shopware\Core\Framework\Feature;
6
7
/**
8
 * @package storefront
9
 *
10
 * @Annotation
11
 *
12
 * @deprecated tag:v6.6.0 - Will be removed use `defaults: {"_httpCache"=true}` or `{"_httpCache"={"maxAge": 360, "states": {"logged-in", "cart-filled"}}}` instead
13
 */
14
class HttpCache
15
{
16
    public const ALIAS = 'httpCache';
17
18
    private ?int $maxAge = null;
19
20
    /**
21
     * @var list<string>|null
0 ignored issues
show
Bug introduced by
The type Shopware\Storefront\Fram...k\Cache\Annotation\list 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
     */
23
    private ?array $states = null;
24
25
    /**
26
     * @param array{maxAge?: int, states?: list<string>} $values
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{maxAge?: int, states?: list<string>} at position 8 could not be parsed: Expected '}' at position 8, but found 'list'.
Loading history...
27
     */
28
    public function __construct(array $values)
29
    {
30
        Feature::triggerDeprecationOrThrow(
31
            'v6.6.0.0',
32
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
33
        );
34
35
        $this->maxAge = $values['maxAge'] ?? null;
36
        $this->states = $values['states'] ?? null;
37
    }
38
39
    public function getAliasName(): string
40
    {
41
        Feature::triggerDeprecationOrThrow(
42
            'v6.6.0.0',
43
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
44
        );
45
46
        return self::ALIAS;
47
    }
48
49
    public function allowArray(): bool
50
    {
51
        Feature::triggerDeprecationOrThrow(
52
            'v6.6.0.0',
53
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
54
        );
55
56
        return true;
57
    }
58
59
    public function getMaxAge(): ?int
60
    {
61
        Feature::triggerDeprecationOrThrow(
62
            'v6.6.0.0',
63
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
64
        );
65
66
        return $this->maxAge;
67
    }
68
69
    public function setMaxAge(?int $maxAge): void
70
    {
71
        Feature::triggerDeprecationOrThrow(
72
            'v6.6.0.0',
73
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
74
        );
75
76
        $this->maxAge = $maxAge;
77
    }
78
79
    /**
80
     * @return list<string>
81
     */
82
    public function getStates(): array
83
    {
84
        Feature::triggerDeprecationOrThrow(
85
            'v6.6.0.0',
86
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
87
        );
88
89
        return $this->states ?? [];
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->states ?? array() returns the type array which is incompatible with the documented return type Shopware\Storefront\Fram...k\Cache\Annotation\list.
Loading history...
90
    }
91
92
    /**
93
     * @param list<string>|null $states
94
     */
95
    public function setStates(?array $states): void
96
    {
97
        Feature::triggerDeprecationOrThrow(
98
            'v6.6.0.0',
99
            Feature::deprecatedClassMessage(__CLASS__, 'v6.6.0.0')
100
        );
101
102
        $this->states = $states;
0 ignored issues
show
Documentation Bug introduced by
It seems like $states of type array is incompatible with the declared type Shopware\Storefront\Fram...k\Cache\Annotation\list of property $states.

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...
103
    }
104
}
105