1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Console;
4:
5: use Salient\Contract\Console\ConsoleFormatterInterface as FormatterInterface;
6: use Salient\Contract\Core\MessageLevel as Level;
7:
8: /**
9: * A console output target
10: *
11: * @api
12: */
13: interface ConsoleTargetInterface
14: {
15: /**
16: * Get an output formatter for the target
17: */
18: public function getFormatter(): FormatterInterface;
19:
20: /**
21: * Get the width of the target in columns
22: *
23: * Returns `null` if output written to the target should not be wrapped.
24: *
25: * Output may exceed the width reported by this method, e.g. if a message
26: * contains preformatted text or a long word.
27: *
28: * The target may truncate long lines if they cannot be displayed or
29: * recorded.
30: */
31: public function getWidth(): ?int;
32:
33: /**
34: * Write formatted output to the target
35: *
36: * @param Level::* $level
37: * @param array<string,mixed> $context
38: */
39: public function write($level, string $message, array $context = []): void;
40:
41: /**
42: * Close the target and any underlying resources
43: */
44: public function close(): void;
45: }
46: