1: <?php declare(strict_types=1);
2:
3: namespace Salient\Console\Target;
4:
5: use Salient\Console\Format\TtyFormat;
6: use Salient\Contract\Console\Format\FormatterInterface;
7: use Salient\Contract\Console\Target\StreamTargetInterface;
8: use Salient\Contract\HasEscapeSequence;
9:
10: /**
11: * @api
12: */
13: abstract class AbstractStreamTarget extends AbstractTargetWithPrefix implements
14: StreamTargetInterface,
15: HasEscapeSequence
16: {
17: /**
18: * @inheritDoc
19: */
20: public function isStdout(): bool
21: {
22: return false;
23: }
24:
25: /**
26: * @inheritDoc
27: */
28: public function isStderr(): bool
29: {
30: return false;
31: }
32:
33: /**
34: * @inheritDoc
35: */
36: public function isTty(): bool
37: {
38: return false;
39: }
40:
41: /**
42: * @inheritDoc
43: */
44: protected function createFormatter(): FormatterInterface
45: {
46: return $this->isTty()
47: ? TtyFormat::getFormatter($this)
48: : parent::createFormatter();
49: }
50: }
51: