private function updateContent(Cron $cron, $key) { $content = $this->cronManipulator->getContent(); $count = 0; $pattern = '/\\r?\\n' . $this->beginKey($key) . '.*?' . self::KEY_END . '/s'; $replacedContent = preg_replace($pattern, $this->wrapInKey($cron, $key), $content, -1, $count); if ($count > 0) { return $replacedContent; } return $this->appendContent($cron, $key, $content); }