1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Console\Support; |
4: | |
5: | use Salient\Contract\Console\ConsoleInterface as Console; |
6: | use Salient\Contract\Console\ConsoleMessageAttributesInterface; |
7: | use Salient\Core\Concern\ImmutableTrait; |
8: | |
9: | /** |
10: | * Message attributes |
11: | */ |
12: | final class ConsoleMessageAttributes implements ConsoleMessageAttributesInterface |
13: | { |
14: | use ImmutableTrait; |
15: | |
16: | /** |
17: | * Message level |
18: | * |
19: | * @readonly |
20: | * @var Console::LEVEL_* |
21: | */ |
22: | public int $Level; |
23: | |
24: | /** |
25: | * Message type |
26: | * |
27: | * @readonly |
28: | * @var Console::TYPE_* |
29: | */ |
30: | public int $Type; |
31: | |
32: | /** |
33: | * True if the text is part 1 of a message |
34: | * |
35: | * @readonly |
36: | */ |
37: | public bool $IsMsg1; |
38: | |
39: | /** |
40: | * True if the text is part 2 of a message |
41: | * |
42: | * @readonly |
43: | */ |
44: | public bool $IsMsg2; |
45: | |
46: | /** |
47: | * True if the text is a message prefix |
48: | * |
49: | * @readonly |
50: | */ |
51: | public bool $IsPrefix; |
52: | |
53: | /** |
54: | * @param Console::LEVEL_* $level |
55: | * @param Console::TYPE_* $type |
56: | */ |
57: | public function __construct( |
58: | int $level, |
59: | int $type, |
60: | bool $isMsg1 = false, |
61: | bool $isMsg2 = false, |
62: | bool $isPrefix = false |
63: | ) { |
64: | $this->Level = $level; |
65: | $this->Type = $type; |
66: | $this->IsMsg1 = $isMsg1; |
67: | $this->IsMsg2 = $isMsg2; |
68: | $this->IsPrefix = $isPrefix; |
69: | } |
70: | |
71: | /** |
72: | * @return static |
73: | */ |
74: | public function withIsMsg1(bool $value = true) |
75: | { |
76: | return $this->with('IsMsg1', $value); |
77: | } |
78: | |
79: | /** |
80: | * @return static |
81: | */ |
82: | public function withIsMsg2(bool $value = true) |
83: | { |
84: | return $this->with('IsMsg2', $value); |
85: | } |
86: | |
87: | /** |
88: | * @return static |
89: | */ |
90: | public function withIsPrefix(bool $value = true) |
91: | { |
92: | return $this->with('IsPrefix', $value); |
93: | } |
94: | } |
95: |