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