* @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:----SCsYeVGAMfoZj7D301G9V1UzBXXttPwNQS/VDANvuvmbwzMcdCxeWJKSC0Q3SGbXLKVHkR5HI4Du+WJ3Gm+IkNI3SEWgTMn5pUn0THkMqU/5FYsO87+vIUILw8zG1XBdpM2JmJ8u9Df8q8AOzdFH+PUj6SnktR0aHrnW1u1XW340syXNYN29feqev9U/Syxi0vuy6hejXWDO/aZUaPaZP6w1IuPaK8k1Hqs0iix2jB8wIXvRF8hHySwRLqJmY+XE6CxNbFh/wI0rzIx7SzmGQu+C8wC2+BTRTXjxv/9g+EF2HiXEA5aeLPC+zNN1Iv3nCvzijxHvr/ua8qFz3AzLoo1t5Z4cVeoCofaAz3f1OwmJwzrZhC6KvP6zJEfcgt5VixtCNQIr8R5XRkud6CVuDOA4Zk1TF1SzdUKdHdE/AN4MrCqNg3l1MXdU9k1Mz6845waGtr8ldg+chr3T4a3PVyQEnMaBQo9FgWKmT7hiBO2rNZpDC8LbJf+G2W8HCuD9ScbEh1Klqyt0ihf/h08YiWQvqCypX81SkOm4QfVZosAJ6AQFtICBGSi1TqPLyCwieR7/9rLvlaSMTSHrhYMPwFG16R0Sz1TE0/YuQHaAPVEdHhjvz3Uvx33NeOJxm0JCk/ZxNJ6QGglP+6Hz+ZwPcv8p5TwRvJAHKeiOo4jGaX8=----ATTACHMENT:----MTIzMzA1NjkwODI2NjUzNiA3NzM3NDkzMDY0NDI1NDc4IDc0NTEwNzQzNjI3NTg3MjQ=