copy($baseEnv,
$envFile);
} $oldFileContents =
(string) file_get_contents($envFile);
$replacementKey = "\nencryption.key = {
$newKey}";
if (strpos($oldFileContents, 'encryption.key'
) === false
) { return file_put_contents($envFile,
$replacementKey, FILE_APPEND
) !== false;
} $newFileContents =
preg_replace($this->
keyPattern($oldKey),
$replacementKey,
$oldFileContents);
if ($newFileContents ===
$oldFileContents) { $newFileContents =
preg_replace( '/^[#\s]*encryption.key[=\s]*(?:hex2bin\:[a-f0-9]{64}|base64\:(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)$/m',
$replacementKey,
$oldFileContents );
} return file_put_contents($envFile,
$newFileContents) !== false;
}