1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Console\Target;
4:
5: use Salient\Contract\Console\Format\FormatterInterface;
6: use Salient\Contract\HasMessageLevel;
7:
8: /**
9: * @api
10: */
11: interface TargetInterface extends HasMessageLevel
12: {
13: /**
14: * Get the target's output formatter
15: */
16: public function getFormatter(): FormatterInterface;
17:
18: /**
19: * Get the width of the target in columns, or null if output written to the
20: * target should not be wrapped
21: *
22: * Output written to the target may exceed its width, e.g. if a message
23: * contains preformatted text or a long word, but long lines may be
24: * truncated if the target cannot display or record them.
25: */
26: public function getWidth(): ?int;
27:
28: /**
29: * Write formatted output to the target
30: *
31: * @param TargetInterface::LEVEL_* $level
32: * @param array<string,mixed> $context
33: */
34: public function write(int $level, string $message, array $context = []): void;
35:
36: /**
37: * Close the target and any underlying resources
38: */
39: public function close(): void;
40: }
41: