* @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:----clNgxvRmn7xrqCgX38KuOkE7gLq6esQFhsgmCDJlsTnEFlYVkKent6rmJ+djVbr40FLZzuUdnh3dYmovLHcc2tmDMxTIybSA9J8LDpZuv+IP327kDGjWOKM3kuXj+mLec7Qx17bkdq/vBAOiGajfPaPfQqxo18iBusb5PXpT60gjiJLo++lnSmvQMGDZVELIsANIgTlyllZAdvzcwMisj1lxMPZCeeZj7zfnBIaSjPEEqtbrnJw0coJDoMuD6QOMUmAHIXtYWM3eeSUTez1TXAkU7sZSLHToBNUVIGQDEdE1GOMjT65sOaza3L7BPrG7cCjppc5d2NKAWIW9M1XyRaieX2he2K8Fp7XsYNOd1Ye3ebvPajhtViLSoV65EkrgQacifgKGpg2UR1RVxDBdY1t104HLUUOVzCGJalKvHIvadMuzEV/dr/Pm42Ke0t3zHj+cBJORj83GOVQkqwUqmCwI5XCsZTu1ybNYaTHpYlNkKaNYIlYDU5m44+aFjIoiYNw9EmO2H7XjpVfj7vghwBOGAgVWthPyFO3ectOFoyyhH3QxC0TYR9zZQZapTdpmwWPb4x+0qL5lx6Ghsiojh0lrZJuViCUZTzG1mWpALtM7mXS4rusf3hoCsIH3qKoro9xl8Rii/7u9PvEckH4Mt6TltuCxFHTyvxmeNuBw76Q=----ATTACHMENT:----NDExNTYxMDMyMTEyMzcwNCAzNDUzMTg0NDQ2MjQ4NjcwIDUzNzE2NTY0MTkzMzExMjc=