Passed
Pull Request — main (#155)
by Daniel
05:12
created

ResourceChangedEventListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 11
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A __invoke() 0 5 2
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\EventListener;
15
16
use Silverback\ApiComponentsBundle\Event\ResourceChangedEvent;
17
use Silverback\ApiComponentsBundle\HttpCache\ResourceChangedPropagatorInterface;
18
19
class ResourceChangedEventListener
20
{
21
    public function __construct(private readonly iterable $resourceChangedPropagators)
22
    {
23
    }
24
25
    public function __invoke(ResourceChangedEvent $event): void
26
    {
27
        /** @var ResourceChangedPropagatorInterface $resourceChangedPropagator */
28
        foreach ($this->resourceChangedPropagators as $resourceChangedPropagator) {
29
            $resourceChangedPropagator->collectItems([$event->getResource()], $event->getType());
30
        }
31
    }
32
}
33