Completed
Push — ezp_30981_content_info_proxy ( 6fc040...a78a98 )
by
unknown
15:33
created

ProxyCacheWarmer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isOptional() 0 4 1
A warmUp() 0 4 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Bundle\EzPublishCoreBundle\Cache\Warmer;
10
11
use eZ\Publish\API\Repository\Values\Content\Content;
12
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
13
use eZ\Publish\API\Repository\Values\Content\Language;
14
use eZ\Publish\API\Repository\Values\Content\Location;
15
use eZ\Publish\API\Repository\Values\Content\Section;
16
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
17
use eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup;
18
use eZ\Publish\API\Repository\Values\User\User;
19
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
20
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
21
22
final class ProxyCacheWarmer implements CacheWarmerInterface
23
{
24
    private const PROXY_CLASSES = [
25
        Content::class,
26
        ContentInfo::class,
27
        ContentType::class,
28
        ContentTypeGroup::class,
29
        Language::class,
30
        Location::class,
31
        Section::class,
32
        User::class,
33
    ];
34
35
    /** @var \eZ\Publish\Core\Repository\ProxyFactory\LazyLoadingValueHolderFactory */
36
    private $lazyLoadingValueHolderFactory;
37
38
    public function __construct(LazyLoadingValueHolderFactory $lazyLoadingValueHolderFactory)
39
    {
40
        $this->lazyLoadingValueHolderFactory = $lazyLoadingValueHolderFactory;
0 ignored issues
show
Documentation Bug introduced by
$lazyLoadingValueHolderFactory is of type object<ProxyManager\Fact...dingValueHolderFactory>, but the property $lazyLoadingValueHolderFactory was declared to be of type object<eZ\Publish\Core\R...dingValueHolderFactory>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
41
    }
42
43
    public function isOptional(): bool
44
    {
45
        return false;
46
    }
47
48
    public function warmUp($cacheDir): void
49
    {
50
        $this->lazyLoadingValueHolderFactory->warmUp(self::PROXY_CLASSES);
51
    }
52
}
53