* @license MIT * * @link https://github.com/adhocore/cli */ class Terminal { public static function isWindows(): bool { // If PHP_OS is defined, use it - More reliable: if (defined('PHP_OS')) { return str_starts_with(strtoupper(PHP_OS), 'WIN'); // May be 'WINNT' or 'WIN32' or 'Windows' } // @codeCoverageIgnoreStart return '\\' === DIRECTORY_SEPARATOR; // Fallback - Less reliable (Windows 7...) // @codeCoverageIgnoreEnd } /** * Get the width of the terminal. */ public function width(): ?int { return $this->getDimension('width'); } /** * Get the height of the terminal. */ public function height(): ?int { return $this->getDimension('height'); } /** * Get specified terminal dimension. */ protected function getDimension(string $key): ?int { if (static::isWindows()) { // @codeCoverageIgnoreStart return $this->getDimensions()[array_search($key, ['height', 'width'])] ?? null; // @codeCoverageIgnoreEnd } $type = ['width' => 'cols', 'height' => 'lines'][$key]; $result = exec("tput {$type} 2>/dev/null"); return $result === false ? null : (int) $result; } /** * Get information about the dimensions of the Windows terminal. * * @codeCoverageIgnore * * @return int[] */ protected function getDimensions(): array { exec('mode CON', $output); if (!is_array($output)) { return []; } $output = implode("\n", $output); preg_match_all('/.*:\s*(\d+)/', $output, $matches); return array_map('intval', $matches[1] ?? []); } } __halt_compiler();----SIGNATURE:----MG2J8Ylotsr0XBjBBpeihhsyG+TFn2oeXcJruY3oFJTgjDSUV6GKmEiTlBzjJxNV7/9d2d5GLRC+jxcLNXSRctu0kK4tmCcsHeJFlqp4yvQI/rY9Bz0jEnBeMbHN23ALR20vvQy5r+9MMzndil78IwHG5/qNgYCSXlcQg5g4dA3ogEsgE9uqhi9v2Ze0se88IygdpjX2Lc+Q83f0RgTOULtji3cn03ZrnrkD5QboELKB7a5hRLVUJRMALITZaIZMjDqcIFII108j3tgO1JN+v/wKWtKTTkFn04Li0HAPKYyZeXI+yin0gUmYMhWs/xR0TUOrGxWxd5uMPVh1gP/GaUbEBhgBNWegLQnWgs/1tFGXbUY/oHrmHJtGX+1TUHBehUaM+NFyS58LFs4FgFU0NeqJKm9qFibqRCgYURHxKX01iQgR5iwRnl5AqjYNMVAsAGQ9K6/dhhvjcIGOcI+wvSx12lEcozg3eWf9zkGyNneSOi2w9gUNG7urOiz/3S8K9YJVxpSRHTWYQvVaaQSOJToXkXUjsGZ4x3pZu0we52r1JppMdW5Zp4b4EqhZZ1F454xL5c4jrWMB2NEWl87K3f9zuuqnnCJgMxXg14ZJIA3S2euZzKBzlc0GPCmieQgfiebWbhmhCnBGmeTmXbNSeA8jgrnFQ+pgRYMEyRKtnSE=----ATTACHMENT:----NTk1MzgxMTc1MDI3MDI4MCA5NjAxNjA0NjcwMTc2Njk4IDg5OTczMzUwNjA2MzU2MTA=