| Total Complexity | 6 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class FlashMessage extends \Yiisoft\Widget\Widget |
||
| 11 | { |
||
| 12 | private Flash $flash; |
||
| 13 | private bool $withoutCloseButton = false; |
||
| 14 | private string $size = ''; |
||
| 15 | |||
| 16 | 8 | public function __construct(Flash $flash) |
|
| 17 | { |
||
| 18 | 8 | $this->flash = $flash; |
|
| 19 | 8 | } |
|
| 20 | |||
| 21 | 8 | public function run(): string |
|
| 22 | { |
||
| 23 | 8 | $flashes = $this->flash->getAll(); |
|
| 24 | 8 | $html = ''; |
|
| 25 | |||
| 26 | 8 | foreach ($flashes as $type => $data) { |
|
| 27 | 2 | foreach ($data as $message) { |
|
| 28 | 2 | $html .= Message::widget() |
|
| 29 | 2 | ->headerColor($type) |
|
|
|
|||
| 30 | 2 | ->headerMessage($message['header'] ?? '') |
|
| 31 | 2 | ->body($message['body'] ?? '') |
|
| 32 | 2 | ->withoutCloseButton($this->withoutCloseButton) |
|
| 33 | 2 | ->size($this->size) |
|
| 34 | 2 | ->render(); |
|
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | 8 | return $html; |
|
| 39 | } |
||
| 40 | |||
| 41 | public function withoutCloseButton(bool $value): self |
||
| 46 | } |
||
| 47 | |||
| 48 | public function size(string $value): self |
||
| 53 | } |
||
| 54 | } |
||
| 55 |