Skip to content

Commit

Permalink
Messages PHP8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Oct 27, 2024
1 parent 6937482 commit e4b370e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Logging/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@

class Message
{
public const LVL_ERROR = 'danger';
public const LVL_WARNING = 'warning';
public const LVL_SUCCESS = 'success';
public const LVL_INFO = 'info';
public const LVL_PRIMARY = 'primary';

public function __construct(
public readonly string|Html $text,
public readonly string $level
public readonly MessageLevel $level
) {
}

Expand All @@ -27,7 +21,7 @@ public function __toArray(): array
{
return [
'text' => ($this->text instanceof Html) ? $this->text->toHtml() : $this->text,
'level' => $this->level,
'level' => $this->level->value,
];
}
}
14 changes: 14 additions & 0 deletions src/Logging/MessageLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Fykosak\Utils\Logging;

enum MessageLevel: string
{
case Error = 'danger';
case Warning = 'warning';
case Success = 'success';
case Info = 'info';
case Primary = 'primary';
}

0 comments on commit e4b370e

Please sign in to comment.