/** {@inheritDoc} */
 public function execute(array $input)
 {
     $text = $this->textSanitizer->sanitize($input);
     $pattern = $input['pattern'];
     $replacement = $input['replacement'];
     $content = $this->contentFactory->make($text);
     $replacedContent = preg_replace($pattern, $replacement, $content);
     $replacedText = Text::fromString($replacedContent);
     $text->setLines($replacedText->getLines());
 }
Esempio n. 2
0
 /**
  * Atomically writes the given File's content on the actual file.
  *
  * @param File $file
  *
  * @throws IOException If the file cannot be written to.
  */
 public function write(File $file)
 {
     $filename = $file->getFilename();
     if (null === $filename) {
         throw new NoFilenameGivenException();
     }
     $content = $this->contentFactory->make($file);
     try {
         $this->symfonyFilesystem->dumpFile($filename, $content, null);
     } catch (SymfonyIOException $e) {
         $message = sprintf('Failed to write "%s".', $filename);
         throw new IOException($filename, $message, $e);
     }
 }