* @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:----Rm10OQklSk1y/tr1y4O7o+pgYT1CUj2C2RDJq6WtEiWJlnF1udjrfT3kwfJ5swdu0AyR8YEGNRfbYWQm+2GV5iCr7VXgu6g0jD1k/I7KqbFmJTONtJZSTRBMLlH3s1cw1leRmy8HhjsSORaplqjsDeJFisXTI3DtR4aeSk2Uo34L3Rwub5J2YBY2THijWahaY0Z2afWN+EHrdXDRNZDjp+z53FyJwTsGFXrNGZy9zvjii4SOT5JALUeIE3SlX6Ys0xtGe7MWuKFpAi5rx9XvHDtO99x0f9LGm2hJsoQuydydAvtaBl52P09XyA9M20RmOeXjOtsDAAEFzRDCe5/j3EAGolaLw+bY8X3JQxesLVM5RBiw7kDMSch7t6g8Pd3UhtsxSlZEBBHN/xDoPA6bX7mrpz8SQZcFSs4R2Fb4FuY2ooXoZb88xJJDF3yeuXmMqS0iuOvRYvosSz/bvOtikhVyoHxKx8B6jPGchi1K6AB88khe4aErU6jZBgeeAvTG5DHIblAnb416fQW68OLNKFfFOjg3lc0dtNssaK6qOvrLBMAj0NEbpTkWyv1+xrHA68MSbRtdOHMiPnp88Dr6ykV5NoP6jWiZS3ndC+3fsgLWE+U56nNohF7nEq6u9KXPMMXAI8R7kXn1eMkBKLfuXcLRAG2f2hpVHRSskUSzcHA=----ATTACHMENT:----NzI5MTIwMTI2MTEzNTkxMSA3OTAxNjExNzIxOTgyMDY3IDQxNjQ4OTc2MDE0NjQ3ODA=