Passed
Push — master ( b68383...74043c )
by Alexander
05:41
created

FlashMessage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
ccs 12
cts 12
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 15 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Widget;
6
7
use Yiisoft\Session\Flash\FlashInterface;
8
use Yiisoft\Yii\Bootstrap5\Alert;
9
use Yiisoft\Widget\Widget;
10
11
final class FlashMessage extends Widget
12
{
13
    private FlashInterface $flash;
14
15 6
    public function __construct(FlashInterface $flash)
16
    {
17 6
        $this->flash = $flash;
18 6
    }
19
20 6
    public function run(): string
21
    {
22 6
        $flashes = $this->flash->getAll();
23
24 6
        $html = [];
25 6
        foreach ($flashes as $type => $data) {
26 2
            foreach ($data as $message) {
27 2
                $html[] = Alert::widget()
28 2
                    ->options(['class' => "alert-{$type} shadow"])
0 ignored issues
show
Bug introduced by
The method options() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Widget\Form or Yiisoft\Yii\Bootstrap5\Nav or Yiisoft\Yii\Bootstrap5\Button or Yiisoft\Yii\Bootstrap5\Carousel or Yiisoft\Yii\Bootstrap5\Progress or Yiisoft\Yii\Bootstrap5\Dropdown or Yiisoft\Yii\Bootstrap5\ButtonDropdown or Yiisoft\Yii\Bootstrap5\Tabs or App\Blog\Widget\PostCard or Yiisoft\Yii\Bootstrap5\Accordion or Yiisoft\Yii\Bootstrap5\Breadcrumbs or App\Widget\OffsetPagination or Yiisoft\Yii\Bootstrap5\Modal or Yiisoft\Yii\Bootstrap5\Alert or Yiisoft\Yii\Bootstrap5\NavBar or Yiisoft\Yii\Bootstrap5\ButtonToolbar or Yiisoft\Yii\Bootstrap5\ButtonGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
                    ->/** @scrutinizer ignore-call */ options(['class' => "alert-{$type} shadow"])
Loading history...
29 2
                    ->body($message['body'])
30
                ;
31
            }
32
        }
33
34 6
        return implode($html);
35
    }
36
}
37