class Tools

Contains functions for miscellaneous tasks.

Constants

BG_BLACK

Value for background black.

BG_RED

Value for background red.

BG_GREEN

Value for background green.

BG_YELLOW

Value for background yellow.

BG_BLUE

Value for background blue.

BG_MAGENTA

Value for background magenta.

BG_CYAN

Value for background cyan.

BG_LIGHT_GREY

Value for background light grey

TEXT_BLACK

Value for text black.

TEXT_WHITE

Value for text white.

TEXT_DARK_GREY

Value for text dark grey.

TEXT_RED

Value for text red.

TEXT_GREEN

Value for text green.

TEXT_BROWN

Value for text brown.

TEXT_YELLOW

Value for text yellow.

TEXT_BLUE

Value for text blue.

TEXT_MAGENTA

Value for text magenta.

TEXT_CYAN

Value for text cyan.

TEXT_LIGHT_CYAN

Value for text light cyan.

TEXT_LIGHT_GREY

Value for text light grey.

TEXT_LIGHT_RED

Value for text light red.

TEXT_LIGHT_GREEN

Value for text light green.

TEXT_LIGHT_BLUE

Value for text light blue.

TEXT_LIGHT_MAGENTA

Value for text light magenta.

Properties

static private OutputInterface|null $output

Supports ability to log information to console.

Methods

static string
border()

Returns dashed border.

static int
createDirWithPrompt(string $directory, InputInterface $cmdInput, OutputInterface $cmdOutput)

Creates a directory. It checks if it already exists. If not, user is asked to confirm the want to create a new directory.

static array|int
dotNotationVerify(string $inputName, InputInterface $input)

Checks if input is in dot notation. If in dot notation the string is placed in an array where the first index is the directory name. The second element is the file name. The structure is shown below:

static bool
hasConstant(string $value, string $type)

Checks if value for background color or text color matches list of available constants.

static void
info(string $message, string $level = Logger::INFO, string $background = self::BG_GREEN, string $text = self::TEXT_LIGHT_GREY)

Generates output messages for console commands.

static void
pathExists(string $path, int $permissions = 0755, bool $recursive = true)

Tests if a path exits and creates it if necessary.

static void
setOutput(OutputInterface $output)

Enables output for symfony.

static int
writeFile(string $path, string $content, string $name)

Generates files for console commands

Details

at line 80
static string border()

Returns dashed border.

Return Value

string

A dashed border.

at line 92
static int createDirWithPrompt(string $directory, InputInterface $cmdInput, OutputInterface $cmdOutput)

Creates a directory. It checks if it already exists. If not, user is asked to confirm the want to create a new directory.

Parameters

string $directory

The full path for the directory to be created.

InputInterface $cmdInput
OutputInterface $cmdOutput

Return Value

int

A value that indicates success, invalid, or failure.

at line 141
static array|int dotNotationVerify(string $inputName, InputInterface $input)

Checks if input is in dot notation. If in dot notation the string is placed in an array where the first index is the directory name. The second element is the file name. The structure is shown below:

["directory_name","file_name"]

If not in the . an error message is displayed an a Command::FAILURE integer value is returned.

Parameters

string $inputName

The name in . format.

InputInterface $input

The Symfony InputInterface object.

Return Value

array|int

An array containing the contents of the $inputName variable. If $inputName is not in correct format then Command::FAILURE is returned.

at line 169
static private bool hasConstant(string $value, string $type)

Checks if value for background color or text color matches list of available constants.

Parameters

string $value

The value of constant passed into info()

string $type

The type of value to determine what type of constant.

Return Value

bool

True if $value matches a available constant for background color or text color.

Exceptions

ConsoleException

at line 199
static void info(string $message, string $level = Logger::INFO, string $background = self::BG_GREEN, string $text = self::TEXT_LIGHT_GREY)

Generates output messages for console commands.

Parameters

string $message

The message we want to show.

string $level

The level of severity for log file. The valid levels are info, debug, warning, error, critical, alert, and emergency.

string $background

The background color. This function supports black, red, green, yellow, blue, magenta, cyan, and light-grey

string $text

The color of the text. This function supports black, white, dark-grey, red, green, brown, blue, magenta, cyan, light-cyan, light-grey, light-red, light green, light-blue, and light-magenta.

Return Value

void

at line 232
static void pathExists(string $path, int $permissions = 0755, bool $recursive = true)

Tests if a path exits and creates it if necessary.

Parameters

string $path

The path to check if it exists.

int $permissions

The permissions for the directory.

bool $recursive

Optional. Specifies if the recursive mode is set.

Return Value

void

at line 244
static void setOutput(OutputInterface $output)

Enables output for symfony.

Parameters

OutputInterface $output

Symfony output.

Return Value

void

at line 256
static int writeFile(string $path, string $content, string $name)

Generates files for console commands

Parameters

string $path

Where the file will be written.

string $content

The contents of the file to be created.

string $name

The name of the file, class, or other relevant information.

Return Value

int

A value that indicates success, invalid, or failure.