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.

SliderJsBlockListener::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusBannerPlugin\Block;
6
7
use Sonata\BlockBundle\Event\BlockEvent;
8
use Sonata\BlockBundle\Model\Block;
9
10
final class SliderJsBlockListener
11
{
12
    /** @var string|null */
13
    private $slider;
14
15
    public function __construct(
16
        ?string $slider
17
    ) {
18
        $this->slider = $slider;
19
    }
20
21
    /**
22
     * @param BlockEvent $event
23
     */
24
    public function onBlockEvent(BlockEvent $event): void
25
    {
26
        $template = null;
27
28
        if (null !== $this->slider) {
29
            $template = '@OdiseoSyliusBannerPlugin/Shop/Slider/_'.$this->slider.'_js.html.twig';
30
        }
31
32
        if (null !== $template) {
33
            $block = new Block();
34
            $block->setId(uniqid('', true));
35
            $block->setSettings(array_replace($event->getSettings(), [
36
                'template' => $template,
37
            ]));
38
            $block->setType('sonata.block.service.template');
39
40
            $event->addBlock($block);
41
        }
42
    }
43
}
44