Skip to content

Commit

Permalink
Add documentation to methods
Browse files Browse the repository at this point in the history
  • Loading branch information
keshikashviligio committed Apr 2, 2018
1 parent 275f990 commit 1e22006
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CliColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ class CliColor
const B_CYAN = '46';
const B_LIGHT_GRAY = '47';

// Returns colored string
/**
* @param $string
* @param null $foregroundColor
* @param null $backgroundColor
* @return string
*/
public static function getColoredString($string, $foregroundColor = null, $backgroundColor = null) {
// Set foreground color and background color
$coloredString = "";
Expand Down
53 changes: 53 additions & 0 deletions CliLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class CliLogger
public $logTextTemplate = "[ {date} | {type} ] - {message} " . PHP_EOL;


/**
* CliLogger constructor.
* @param $config
*/
public function __construct($config)
{
if (!empty($config)) {
Expand All @@ -49,30 +53,59 @@ public function __construct($config)
}


/**
* @param $message
* @param string $fColor
* @param null $bColor
* @param string $type
* @return string
*/
public function log($message, $fColor = CliColor::F_WHITE, $bColor = null, $type = 'LOG')
{
return $this->writeLog($this->processLogTextTemplate($message, $type), $fColor, $bColor);
}


/**
* @param $message
* @param string $type
* @return string
*/
public function error($message, $type = 'ERROR')
{
return $this->writeLog($this->processLogTextTemplate($message, $type), CliColor::F_RED);
}


/**
* @param $message
* @param string $type
* @return string
*/
public function info($message, $type = 'INFO')
{
return $this->writeLog($this->processLogTextTemplate($message, $type), CliColor::F_LIGHT_BLUE);
}


/**
* @param $message
* @param string $type
* @return string
*/
public function success($message, $type = 'SUCCESS')
{
return $this->writeLog($this->processLogTextTemplate($message, $type), CliColor::F_LIGHT_GREEN);
}


/**
* @param $message
* @param $fColor
* @param null $bColor
* @return string
* @throws \Exception
*/
private function writeLog($message, $fColor, $bColor = null)
{
if (!file_exists($this->logFilePath)) {
Expand All @@ -90,6 +123,11 @@ private function writeLog($message, $fColor, $bColor = null)
}


/**
* @param $object
* @param $properties
* @return mixed
*/
private function configure($object, $properties)
{
foreach ($properties as $name => $value) {
Expand All @@ -100,6 +138,10 @@ private function configure($object, $properties)
}


/**
* @param $expiredLogFile
* @return bool|mixed|string
*/
private function processFileTemplate($expiredLogFile)
{

Expand Down Expand Up @@ -132,6 +174,11 @@ private function processFileTemplate($expiredLogFile)
}


/**
* @param $message
* @param string $type
* @return string
*/
private function processLogTextTemplate($message, $type = 'LOG')
{
$parts = [
Expand All @@ -144,6 +191,9 @@ private function processLogTextTemplate($message, $type = 'LOG')
}


/**
* @return bool|mixed
*/
private function checkFileCreation()
{
$logFileName = $this->getLatestLogFile();
Expand Down Expand Up @@ -173,6 +223,9 @@ private function checkFileCreation()
}


/**
* @return bool|mixed
*/
private function getLatestLogFile()
{
$files = [];
Expand Down

0 comments on commit 1e22006

Please sign in to comment.