public function updateExistingLines($lines, $version, $comment, $options)
{
if (!isset($options['type'])) {
throw new \InvalidArgumentException('Option [type] in mandatory');
}
$type = $options['type'];
if (!in_array($type, array('patch', 'minor', 'major'))) {
throw new \InvalidArgumentException("Invalid type [{$type}]");
}
// Specific case for new Changelog file. We always have to write down a major
if (count($lines) == 0) {
$type = 'major';
}
// Insert the new lines
array_splice($lines, $this->findPositionToInsert($lines, $type), 0, $this->getNewLines($type, $version, $comment));
// Insert extra lines (like commits details)
if (isset($options['extra-lines'])) {
foreach ($options['extra-lines'] as $pos => $line) {
$options['extra-lines'][$pos] = ' ' . $line;
}
array_splice($lines, $this->findPositionToInsert($lines, 'patch') + 1, 0, $options['extra-lines']);
}
return $lines;
}