* @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:----wsYRQrzZgvn2kNjDD4aAcB3DkjP+RLzx+cYX5p2IzSxhuNyXxRoP4ziymJ5UgMAYSmGfwOUFQzfbJJddSxuyf9QxxexyNNSSraDv7Bga6aIx8QIzRd5PKshtene5wdHhoQ2fGMHVbOPIeP6lLVJ+FfXsSrKApvnIzvrJror1U02KeY6Qu59mCqD33tt6OBD8MlPsLtjgJMuSo3j67wJNmFD32QrUr9pB2/LOZ72oFskPi5O03WTp1vLb2YW/zC9OC+Jjvci2PuT9Xb9mrFPFcFB7pwk5meSvDRDg6UkiBXCMVYOPgNrvF8aYB+eSf3MIerL3Bq11gbxMTXjDYyGptdc4gd9EQ8kH1ovlU7ZelStbO9L5NOB/iOIKw1Z56kA01Fgn2Nk48jm8yWKJj5uByBQGXXNjQ4BJIC/IyY+7czWZrtcHOwaMOe9vm5+h6Tt5hpogzaEibviB9WHbbV5AcUmBQCmQ1wIuMeXqoD+t0Hy/HoqkkF6ZiTGvsh0DwB5UplKru4VsYN3CbNyeqENww4P9fhaVJWvQL/jmIKbeXrbwE0vRYxK4ed7eyXAtLKlve7cT00tuVG41CGzABtjtiPt04ysE3JATAB/8PhC2GN7KgA8uSzhr4dh4QoLaXYrYy9GUtNak5ZtQ006FHwZ9exZdTBaYcCJhSrALTrvqY5Y=----ATTACHMENT:----NTY0NzMxNzQyNzI4MjkwOCAyNzc5MzkzOTc5NDYxOTU3IDk0ODE3Mjk5NTcxMzc4ODY=