private static function createFunctionInMemory(string $string): void
{
$file_name = getmypid() . '_' . md5($string);
$tmp_path = JFactory::getApplication()->get('tmp_path', JPATH_ROOT . '/tmp');
$temp_file = $tmp_path . '/regularlabs/custom_php/' . $file_name;
// Write file
if ( ! file_exists($temp_file) || is_writable($temp_file))
{
JFile::write($temp_file, $string);
}
// Include file
include_once $temp_file;
// Delete file
if ( ! JFactory::getApplication()->get('debug'))
{
@chmod($temp_file, 0777);
@unlink($temp_file);
}
}