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

UnusedMediaSearchEvent::markAsUsed()   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
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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