Example #1
0
 /**
  * Apply filter
  * @param  \NMC\Migration\ObjectInterface $object
  * @throws \RuntimeException              If error during replacement
  */
 public function apply(\NMC\Migration\ObjectInterface $object)
 {
     $content = preg_replace_callback($this->pattern, $this->callback, $object->getContent());
     if ($content === null) {
         throw new \RuntimeException('Error while replacing values');
     }
     $object->setContent($content);
 }
Example #2
0
 /**
  * Apply filter
  * @param  \NMC\Migration\ObjectInterface $object
  * @throws \RuntimeException             If provided match index does not exist in match result set
  */
 public function apply(\NMC\Migration\ObjectInterface $object)
 {
     $result = preg_match($this->pattern, $object->getContent(), $matches);
     if (is_array($matches) === true && count($matches) > 0) {
         if (isset($matches[$this->matchIndex]) === false) {
             throw new \RuntimeException('Invalid match index `' . $this->matchIndex . '`. Index does not exist.');
         }
         $object->setContent($matches[$this->matchIndex]);
     }
 }
Example #3
0
 public function run(\NMC\Migration\ObjectInterface $object)
 {
     echo $object->getContent();
 }