* @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:----bD79PEBzV88urNU5AAFl7G3Z0ByhjfVpl1cyDiMOmqJZrgZm23hE18PT249VGUBnxe2d+soyM83kvMb7+zgK4JmMXE5OPDUpwmlIQQ5Jh1hRmkPfFXWgorEuEzX0jXf+D+rLs+0PIXgnFNj7zAhl5xxpnMCYJX8guxL/4w483Gfs0hPpJZBLHkvCfII8qubs2MS5Yxtix7PzeHEztJ2330CCS9B+TcyWrAols0cxGxtSQkI8PfAwMKg4m0bhswDkp8ULRYGLhqMrfr+AyrH6TuH4iNCy/esysQs/yVAqZ/TPadrt1lnWFhJ935ZYlXcjP2SJEOpGvtsnUiZyET83iyPuB9u8BFuBWlwmqnMPMnsyn55kzqP9ob8gNFK/N48ndToEx6/XTu/svQjc+Fozyi3hOON1jdNpIrpdrPYmmkW0K0/Pw5yOH32imtW3Alt0+LHOkpvemgwLnmjGmNtKfhtfueFC24BZS9e6mKB3EqfYD1gFIhbUtViJ9vlJJZBuN/DftvTiLfGuNnbks2oc++D+ypOcbksKNrw5TP1ldb6JgLmFiM688jHqMcdnFY8UaNzZSR3B5nUgD9WBGq3W+vq6rpUEaB7e5RwWJhU9oeNll7zxwbahVE0p8pbBwkzC+pO83AyV6OYFzVHXmjoQPpDwAH+eE4EphYbBE3mYQFo=----ATTACHMENT:----Mzk2ODE3MDQ0MDUwNzg1OSA5NDU4ODE1MTE5ODU5MDE0IDIxNzkzNTgyMTkyMDUzNTg=