protected function updateFile($filename)
{
$current = Context::getParam('current-version');
$next = Context::getParam('new-version');
$content = file_get_contents($filename);
if (false === strpos($content, $current)) {
throw new Exception('The version class ' . $filename . " does not contain the current version {$current}");
}
if (isset($this->options['pattern'])) {
$current = str_replace('%version%', $current, $this->options['pattern']);
$next = str_replace('%version%', $next, $this->options['pattern']);
}
$content = str_replace($current, $next, $content);
if (false === strpos($content, $next)) {
throw new Exception('The version class ' . $filename . " could not be updated with version {$next}");
}
file_put_contents($filename, $content);
}