jcb-compiler/src/7c07c9d6-34cd-4491-934a-ef0.../code.power

55 lines
1.2 KiB
Plaintext

/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
}
/**
* Set a string as bsae64 (basic)
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string
{
if (\strpos($script, 'LOCK'.'BASE64((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'LOCK'.'BASE64((((', '))))'
);
$locker = [];
// convert them
foreach ($values as $value)
{
$locker['LOCK'.'BASE64((((' . $value . '))))']
= "base64_decode( preg_replace('/\s+/', ''," .
PHP_EOL . Indent::_(2) . "'" .
wordwrap(
base64_encode((string) $value), 64, PHP_EOL . Indent::_(2), true
) .
"'))";
}
// update the script
return $this->placeholder->update($script, $locker);
}
return $script;
}