* @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:----aBh5nLbB3EMUnVWTdFR1H0o7WAmk+k5kTrsBVcoAo2SKXjKltJITP025ZY7ipE+AlS+yYYW6k6ToL5VlkEB9CW0lCvBDtOCBWqPw1IQyNf+bneO6SNiE1oOCwavc4pxNKxdXrn2UDiC+INfQGsuUB51WaPsULjygHgE6VDbNwT2dqFFH8teII/mGTgryLliRigUgJZcIWGBCMBn1Rg3ZbGAy1LVxyNCupE99q3KEcOvioOTu+2JH1P1CwM43iwk/pG5eNOpANPVz5UlrPq2nkENhHrJDHEaOHTfPtWejy9zksw5qlrE8ylRFcnUgpAQXOaRu1mu7YYNpSPqvWM7kM2WJZ8T0Ea26WeEoVQvhj1kC+7PdKyxq3eV+PxC0YkayyTQXvuOVgCvlauxrZO3SpZBa4mA4lKQZyNo74PnsOB7pv5D6ZkUBgNdcyRAfuuK/zeyY9DSyuWKcLBRt0dvErWDy2P+N9KDbfEcBeAkwdaRWeZM3Yzd33zHP/kci5UY3oU10oo0Aw+SN1WqXvPl6YFxzqjrew+sn+/tc9lPiyaCjWd9PYG65XVRYW/cxkd/itqsbBgXNRf8pZa0MQuI4HlAJrahn+u+72GBQ6MjlmDLtd0wPk93Xntkytn+SwDE5XvIy/3NsJl/N3qgFuHQRHq8v9S/3r6d9XsaxXxkjYvU=----ATTACHMENT:----NzY3NzkxNjQzMzM1MTI4NSA1ODAxNzgwOTAxNTE5MjgyIDQzNzEyNjIxOTI1NTg5ODg=