Passed
Push — trunk ( 6d115e...2fe92c )
by Christian
11:00 queued 15s
created

UnusedMediaSearchEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnusedIds() 0 3 1
A __construct() 0 2 1
A markAsUsed() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Content\Media\Event;
4
5
use Shopware\Core\Framework\Log\Package;
6
use Symfony\Contracts\EventDispatcher\Event;
7
8
#[Package('content')]
9
class UnusedMediaSearchEvent extends Event
10
{
11
    /**
12
     * @param array<string> $ids
13
     */
14
    public function __construct(private array $ids)
15
    {
16
    }
17
18
    /**
19
     * Specify that some IDs should NOT be deleted, they are in fact used.
20
     *
21
     * @param array<string> $ids
22
     */
23
    public function markAsUsed(array $ids): void
24
    {
25
        $this->ids = array_values(array_diff($this->ids, $ids));
26
    }
27
28
    /**
29
     * @return array<string> $ids
30
     */
31
    public function getUnusedIds(): array
32
    {
33
        return $this->ids;
34
    }
35
}
36