| Total Complexity | 2 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | abstract class ATerminal implements ITerminal |
||
| 12 | { |
||
| 13 | private static ?ITerminal $instance = null; |
||
| 14 | private ColorMode $colorMode; |
||
| 15 | private int $width; |
||
| 16 | |||
| 17 | private function __construct(iterable $terminalProbes) |
||
| 18 | { |
||
| 19 | /** @var ITerminalProbe $terminalProbe */ |
||
| 20 | foreach ($terminalProbes as $terminalProbe) { |
||
| 21 | if ($terminalProbe::isSupported()) { |
||
| 22 | $this->colorMode = $terminalProbe::getColorMode(); |
||
| 23 | $this->width = $terminalProbe::getWidth(); |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | } |
||
| 27 | $this->colorMode = ITerminal::TERMINAL_DEFAULT_COLOR_SUPPORT; |
||
| 28 | $this->width = ITerminal::TERMINAL_DEFAULT_WIDTH; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getColorMode(): ColorMode |
||
| 32 | { |
||
| 33 | return $this->colorMode; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function setColorMode(ColorMode $colorMode): void |
||
| 37 | { |
||
| 38 | $this->colorMode = $colorMode; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function getWidth(): int |
||
| 42 | { |
||
| 43 | return $this->width; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function setWidth(int $width): void |
||
| 49 | } |
||
| 50 | |||
| 51 | final public static function getInstance(iterable $terminalProbes): self |
||
| 59 | } |
||
| 60 | } |