Convert RuntimeConstants constants to enum cases
This commit is contained in:
parent
e02f1f56dc
commit
0d9f3d37a3
3 changed files with 14 additions and 14 deletions
|
@ -257,7 +257,7 @@
|
||||||
|
|
||||||
if(function_exists('getcwd'))
|
if(function_exists('getcwd'))
|
||||||
{
|
{
|
||||||
$input = str_replace(RuntimeConstants::CWD, getcwd(), $input);
|
$input = str_replace(RuntimeConstants::CWD->value, getcwd(), $input);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -266,7 +266,7 @@
|
||||||
|
|
||||||
if(function_exists('getmypid'))
|
if(function_exists('getmypid'))
|
||||||
{
|
{
|
||||||
$input = str_replace(RuntimeConstants::PID, getmypid(), $input);
|
$input = str_replace(RuntimeConstants::PID->value, getmypid(), $input);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -275,7 +275,7 @@
|
||||||
|
|
||||||
if(function_exists('getmyuid'))
|
if(function_exists('getmyuid'))
|
||||||
{
|
{
|
||||||
$input = str_replace(RuntimeConstants::UID, getmyuid(), $input);
|
$input = str_replace(RuntimeConstants::UID->value, getmyuid(), $input);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
|
|
||||||
if(function_exists('getmygid'))
|
if(function_exists('getmygid'))
|
||||||
{
|
{
|
||||||
$input = str_replace(RuntimeConstants::GID, getmygid(), $input);
|
$input = str_replace(RuntimeConstants::GID->value, getmygid(), $input);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -293,7 +293,7 @@
|
||||||
|
|
||||||
if(function_exists('get_current_user'))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
namespace ncc\Enums\SpecialConstants;
|
namespace ncc\Enums\SpecialConstants;
|
||||||
|
|
||||||
final class RuntimeConstants
|
enum RuntimeConstants : string
|
||||||
{
|
{
|
||||||
public const CWD = '%CWD%';
|
case CWD = '%CWD%';
|
||||||
public const PID = '%PID%';
|
case PID = '%PID%';
|
||||||
public const UID = '%UID%';
|
case UID = '%UID%';
|
||||||
public const GID = '%GID%';
|
case GID = '%GID%';
|
||||||
public const USER = '%USER%';
|
case USER = '%USER%';
|
||||||
}
|
}
|
|
@ -81,7 +81,7 @@
|
||||||
public function __construct(string $target, ?string $working_directory=null)
|
public function __construct(string $target, ?string $working_directory=null)
|
||||||
{
|
{
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
$this->working_directory = $working_directory ?? RuntimeConstants::CWD;
|
$this->working_directory = $working_directory ?? RuntimeConstants::CWD->value;
|
||||||
$this->options = [];
|
$this->options = [];
|
||||||
$this->environment_variables = [];
|
$this->environment_variables = [];
|
||||||
$this->silent = false;
|
$this->silent = false;
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
*/
|
*/
|
||||||
public function getWorkingDirectory(): string
|
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
|
public function setWorkingDirectory(?string $working_directory): void
|
||||||
{
|
{
|
||||||
$this->working_directory = $working_directory ?? RuntimeConstants::CWD;
|
$this->working_directory = $working_directory ?? RuntimeConstants::CWD->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue