Esempio n. 1
0
 /**
  * Converts multiple replaced strings with the original values
  *
  * @param string  $text  Text to consider for unreplacing
  * @param bool  $include_type  Should we include the quotes with it?
  * @return string
  */
 private static function unreplaceAll($text, $include_type = false)
 {
     // check that there's an unreplace-able string here
     if (!is_string($text) || strpos($text, '__r@-') === false) {
         // nothing unreplace-able, return the text
         return $text;
     }
     // return the text with all placeholders unreplaced
     while (strpos($text, '__r@-') !== false) {
         $text = preg_replace_callback('/__r@-\\d+__/', function ($matches) use($include_type) {
             // $matches is a list of unreplacement placeholder keys
             if ($include_type) {
                 // $include_type means that we want to add in the same quotes (single or double) that this originally came with
                 return Dipper::$replacement_types[$matches[0]] . Dipper::unreplaceDeep($matches[0]) . Dipper::$replacement_types[$matches[0]];
             }
             // otherwise, just use the text saved without its surrounding quotes
             return Dipper::unreplaceDeep($matches[0]);
         }, $text);
     }
     return $text;
 }
Esempio n. 2
0
 /**
  * Converts multiple replaced strings with the original values
  *
  * @param string  $text  Text to consider for unreplacing
  * @param bool  $include_type  Should we include the quotes with it?
  * @return string
  */
 private static function unreplaceAll($text, $include_type = false)
 {
     // check that there's an unreplace-able string here
     if (!is_string($text) || strpos($text, '__r@-') === false) {
         return $text;
     }
     // unreplace all
     return preg_replace_callback('/__r@-\\d+__/', function ($matches) use($include_type) {
         if ($include_type) {
             // we want to add in the same quotes (single or double) that this originally came with
             return Dipper::$replacement_types[$matches[0]] . Dipper::unreplace($matches[0]) . Dipper::$replacement_types[$matches[0]];
         }
         return Dipper::unreplace($matches[0]);
     }, $text);
 }