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