| @@ 24-38 (lines=15) @@ | ||
| 21 | * |
|
| 22 | * @return int |
|
| 23 | */ |
|
| 24 | public function getWidth() |
|
| 25 | { |
|
| 26 | if (null === $this->width && !$this->initialised) { |
|
| 27 | $this->refreshDimensions(); |
|
| 28 | } |
|
| 29 | ||
| 30 | if (null === $this->width) { |
|
| 31 | $width = getenv('COLUMNS'); |
|
| 32 | if (false !== $width) { |
|
| 33 | $this->width = (int) trim($width); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| 37 | return $this->width ?: static::DEFAULT_WIDTH; |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Gets the terminal height. |
|
| @@ 45-59 (lines=15) @@ | ||
| 42 | * |
|
| 43 | * @return int |
|
| 44 | */ |
|
| 45 | public function getHeight() |
|
| 46 | { |
|
| 47 | if (null === $this->height && !$this->initialised) { |
|
| 48 | $this->refreshDimensions(); |
|
| 49 | } |
|
| 50 | ||
| 51 | if (null === $this->height) { |
|
| 52 | $height = getenv('LINES'); |
|
| 53 | if (false !== $height) { |
|
| 54 | $this->height = (int) trim($height); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | return $this->height ?: static::DEFAULT_HEIGHT; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Refresh the current dimensions from the terminal |
|