Added Runtime Constant compiler
This commit is contained in:
parent
bb0eb22f26
commit
0010a7257c
2 changed files with 30 additions and 2 deletions
|
@ -5,4 +5,9 @@
|
|||
abstract class RuntimeConstants
|
||||
{
|
||||
const CWD = '%CWD%';
|
||||
|
||||
const PID = '%PID%';
|
||||
const UID = '%UID%';
|
||||
const GID = '%GID%';
|
||||
const User = '%USER%';
|
||||
}
|
|
@ -6,9 +6,8 @@
|
|||
use ncc\Abstracts\SpecialConstants\DateTimeConstants;
|
||||
use ncc\Abstracts\SpecialConstants\InstallConstants;
|
||||
use ncc\Abstracts\SpecialConstants\AssemblyConstants;
|
||||
use ncc\Abstracts\SpecialConstants\RuntimeConstants;
|
||||
use ncc\Objects\InstallationPaths;
|
||||
use ncc\Objects\Package;
|
||||
use ncc\Objects\ProjectConfiguration;
|
||||
use ncc\Objects\ProjectConfiguration\Assembly;
|
||||
|
||||
class ConstantCompiler
|
||||
|
@ -126,4 +125,28 @@
|
|||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $input
|
||||
* @return string|null
|
||||
* @noinspection PhpUnnecessaryLocalVariableInspection
|
||||
*/
|
||||
public static function compileRuntimeConstants(?string $input): ?string
|
||||
{
|
||||
if ($input == null)
|
||||
return null;
|
||||
|
||||
if(function_exists('getcwd'))
|
||||
$input = str_replace(RuntimeConstants::CWD, getcwd(), $input);
|
||||
if(function_exists('getmypid'))
|
||||
$input = str_replace(RuntimeConstants::PID, getmypid(), $input);
|
||||
if(function_exists('getmyuid'))
|
||||
$input = str_replace(RuntimeConstants::UID, getmyuid(), $input);
|
||||
if(function_exists('getmygid'))
|
||||
$input = str_replace(RuntimeConstants::GID, getmygid(), $input);
|
||||
if(function_exists('get_current_user'))
|
||||
$input = str_replace(RuntimeConstants::User, get_current_user(), $input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue