private function updateConfig($value, $replaceRegex, $definitionTemplate, $usePlainValue)
{
$wpConfigContent = file_get_contents($this->wpConfigPath);
$phpizedValue = $usePlainValue ? $value : var_export($value, true);
$configContainsDefinition = preg_match($replaceRegex, $wpConfigContent);
if ($configContainsDefinition) {
$wpConfigContent = preg_replace($replaceRegex, "\${1}{$phpizedValue}\${2}", $wpConfigContent);
} else {
$originalContent = $wpConfigContent;
$endOfEditableSection = $this->isCommonConfig ? strlen($originalContent) : $this->findPositionForAddingNewDefinition($wpConfigContent);
if ($endOfEditableSection === false) {
throw new \Exception('Editable section not found.');
}
$wpConfigContent = substr($originalContent, 0, $endOfEditableSection);
$wpConfigContent .= sprintf($definitionTemplate, $phpizedValue);
$wpConfigContent .= substr($originalContent, $endOfEditableSection);
}
file_put_contents($this->wpConfigPath, $wpConfigContent);
}