Text UI
A simple and fast way to take user input and display output in text mode using PHP.
Loading...
Searching...
No Matches
Utils Class Reference

Static Public Member Functions

static isRunningInCliMode ()
 
static detectOS ()
 
static detectScreenColumns ()
 
static getDiffBetweenTimes (int $timestamp1, int $timestamp2)
 
static strToParagraph (string $text, int $len)
 

Detailed Description

Utils for TextUI.

Author
everton3x

Definition at line 15 of file Utils.php.

Member Function Documentation

◆ detectOS()

static detectOS ( )
static

Detects what the operating system is.

Returns
OperatingSystem
Exceptions
UnknowOSException

Definition at line 39 of file Utils.php.

◆ detectScreenColumns()

static detectScreenColumns ( )
static

Detects the number of columns in the terminal.

Returns
int
Exceptions
UnknowOSException

Definition at line 57 of file Utils.php.

◆ getDiffBetweenTimes()

static getDiffBetweenTimes ( int $timestamp1,
int $timestamp2 )
static

Calculates the number of years, months, days, hours, minutes and seconds between two timestamps.

Parameters
int$timestamp1
int$timestamp2
Returns
array<int> Array with keys years, months, days, hours, minutes and seconds.

Definition at line 85 of file Utils.php.

◆ isRunningInCliMode()

static isRunningInCliMode ( )
static

Detects if the script is running in CLI mode.

Returns
bool TRUE = CLI mode.

Definition at line 22 of file Utils.php.

◆ strToParagraph()

static strToParagraph ( string $text,
int $len )
static

Breaks a string into an array where each element has the length defined by $len.

First, the string is split by the PHP_EOL line breaks, only after that, the lines longer than $len are also broken.

Parameters
string$text
int<1,max>$len
Returns
array<string>

Definition at line 117 of file Utils.php.


The documentation for this class was generated from the following file: