Convert RuntimeConstants constants to enum cases

This commit is contained in:
netkas 2024-09-14 08:32:13 -04:00
parent e02f1f56dc
commit 0d9f3d37a3
3 changed files with 14 additions and 14 deletions

View file

@ -257,7 +257,7 @@
if(function_exists('getcwd'))
{
$input = str_replace(RuntimeConstants::CWD, getcwd(), $input);
$input = str_replace(RuntimeConstants::CWD->value, getcwd(), $input);
}
else
{
@ -266,7 +266,7 @@
if(function_exists('getmypid'))
{
$input = str_replace(RuntimeConstants::PID, getmypid(), $input);
$input = str_replace(RuntimeConstants::PID->value, getmypid(), $input);
}
else
{
@ -275,7 +275,7 @@
if(function_exists('getmyuid'))
{
$input = str_replace(RuntimeConstants::UID, getmyuid(), $input);
$input = str_replace(RuntimeConstants::UID->value, getmyuid(), $input);
}
else
{
@ -284,7 +284,7 @@
if(function_exists('getmygid'))
{
$input = str_replace(RuntimeConstants::GID, getmygid(), $input);
$input = str_replace(RuntimeConstants::GID->value, getmygid(), $input);
}
else
{
@ -293,7 +293,7 @@
if(function_exists('get_current_user'))
{
$input = str_replace(RuntimeConstants::USER, get_current_user(), $input);
$input = str_replace(RuntimeConstants::USER->value, get_current_user(), $input);
}
else
{

View file

@ -22,11 +22,11 @@
namespace ncc\Enums\SpecialConstants;
final class RuntimeConstants
enum RuntimeConstants : string
{
public const CWD = '%CWD%';
public const PID = '%PID%';
public const UID = '%UID%';
public const GID = '%GID%';
public const USER = '%USER%';
case CWD = '%CWD%';
case PID = '%PID%';
case UID = '%UID%';
case GID = '%GID%';
case USER = '%USER%';
}

View file

@ -81,7 +81,7 @@
public function __construct(string $target, ?string $working_directory=null)
{
$this->target = $target;
$this->working_directory = $working_directory ?? RuntimeConstants::CWD;
$this->working_directory = $working_directory ?? RuntimeConstants::CWD->value;
$this->options = [];
$this->environment_variables = [];
$this->silent = false;
@ -116,7 +116,7 @@
*/
public function getWorkingDirectory(): string
{
return $this->working_directory ?? RuntimeConstants::CWD;
return $this->working_directory ?? RuntimeConstants::CWD->value;
}
/**
@ -127,7 +127,7 @@
*/
public function setWorkingDirectory(?string $working_directory): void
{
$this->working_directory = $working_directory ?? RuntimeConstants::CWD;
$this->working_directory = $working_directory ?? RuntimeConstants::CWD->value;
}
/**