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.

SliderCssBlockListener::onBlockEvent()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 10
c 1
b 0
f 1
nc 4
nop 1
dl 0
loc 17
rs 9.9332
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 SliderCssBlockListener
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.'_css.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