Total Complexity | 9 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | trait ImagesAwareTrait |
||
12 | { |
||
13 | /** @var Collection|ImageInterface[] */ |
||
14 | protected $images; |
||
15 | |||
16 | public function initializeImagesCollection(): void |
||
17 | { |
||
18 | $this->images = new ArrayCollection(); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | public function getImages(): Collection |
||
25 | { |
||
26 | return $this->images; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | public function getImagesByType(string $type): Collection |
||
33 | { |
||
34 | return $this->images->filter(function (ImageInterface $image) use ($type) { |
||
35 | return $type === $image->getType(); |
||
36 | }); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function hasImages(): bool |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function hasImage(ImageInterface $image): bool |
||
51 | { |
||
52 | return $this->images->contains($image); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function addImage(ImageInterface $image): void |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function removeImage(ImageInterface $image): void |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 |