Passed
Pull Request — master (#566)
by Rustam
01:47
created

FlashMessage::render()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Widget;
6
7
use Yiisoft\Session\Flash\FlashInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Session\Flash\FlashInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Yiisoft\Widget\Widget;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Widget\Widget was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Yiisoft\Yii\Bootstrap5\Alert;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\Bootstrap5\Alert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
final class FlashMessage extends Widget
12
{
13
    public function __construct(private FlashInterface $flash)
14
    {
15
    }
16
17
    public function render(): string
18
    {
19
        $flashes = $this->flash->getAll();
20
21
        $html = [];
22
        foreach ($flashes as $type => $data) {
23
            foreach ($data as $message) {
24
                $html[] = Alert::widget()
25
                    ->options(['class' => "alert-{$type} shadow"])
26
                    ->body($message['body']);
27
            }
28
        }
29
30
        return implode($html);
31
    }
32
}
33