GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ArticleImageUploadListener::uploadImages()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\BlogBundle\EventListener;
6
7
use Odiseo\BlogBundle\Model\ArticleInterface;
8
use Odiseo\BlogBundle\Model\ImageInterface;
9
use Odiseo\BlogBundle\Uploader\ImageUploaderInterface;
10
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
11
use Webmozart\Assert\Assert;
12
13
final class ArticleImageUploadListener
14
{
15
    /** @var ImageUploaderInterface */
16
    private $uploader;
17
18
    public function __construct(ImageUploaderInterface $uploader)
19
    {
20
        $this->uploader = $uploader;
21
    }
22
23
    public function uploadImages(ResourceControllerEvent $event): void
24
    {
25
        $article = $event->getSubject();
26
27
        Assert::isInstanceOf($article, ArticleInterface::class);
28
29
        $images = $article->getImages();
30
31
        /** @var ImageInterface $image */
32
        foreach ($images as $image) {
33
            if (null !== $image && true === $image->hasFile()) {
34
                $this->uploader->upload($image);
35
            }
36
        }
37
    }
38
}
39