Replace the insert tag.

@param array $elements

@return string
438472
private function replaceInsertTag(array $elements): string
    {
        if (3 !== \count($elements)) {
            return '';
        }

        list($source, $value, $property) = $elements;

        $tag = $this->registry->get($source)->find($value);

        if (null === $tag) {
            return '';
        }

        if ('name' === $property) {
            return $tag->getName();
        }

        $data = $tag->getData();

        return isset($data[$property]) ? (string) $data[$property] : '';
    }
141519
public function replace(array $placeholders = [])
    {
        if (empty($placeholders)) {
            return $this;
        }
        $callback = function ($value) use ($placeholders) {
            return StringHelper::replace($value, $placeholders, false);
        };
        $this->data = ArrayHelper::map($this->data, $callback, true);
        return $this;
    }
783744
public function appendChild(Element $element)
	{
		$this->beforeInsert($element);
		
		array_push($this->children, $element);
		
		$this->afterInsert();
		
		return $this;
	}
497073
public function replace(string $text, Array $data): string {
    $replaceText = $text;
    if (!empty($text) && count($data)) {
      foreach ($data as $key => $value) {
        $replaceText = preg_replace("#(\{data\:{$key}\})#i", $value, $replaceText);
      }
    }
    return $replaceText;
  }
504171
public function replaceBlock(BlockElement $block, array $children = null)
    {
        if ($parent = $block->getParent()) {
            foreach (array_reverse($children ?: $block->getChildren()) as $child) {
                $parent->insertAfter($block, $child);
            }
            $previous = $block->getPreviousSibling();
            if ($previous instanceof TextElement) {
                $previous->setEnd(true);
            }
            $block->remove();
        }
    }
604573
public static function replace($text, array $replacements = [], $prefix = '{', $suffix = '}')
    {
        $replacements = static::prepareBinding($replacements, $prefix, $suffix);

        $filter = function ($text) use ($replacements) {
            return strtr($text, $replacements);
        };

        if (is_array($text)) {
            $text = array_map($filter, $text);
        } else {
            $text = $filter($text);
        }

        return $text;
    }
423794
public function addElementArray(array $elements) {

		if(count($elements)) {
			
			$firstElement = array_shift($elements);
			$name = $firstElement->getName();

			// remove any array indexes from name

			$name = preg_replace('~\[\w*\]$~i', '', $name);

			if(!empty($this->elements[$name])) {

				throw new HtmlFormException(sprintf("Element '%s' already assigned.", $name));

			}

			$arrayName = $name . '[]';
			$firstElement
				->setName($arrayName)
				->setForm($this)
			;

			$this->elements[$name] = [$firstElement];

			foreach($elements as $e) {
				
				if(get_class($e) !== get_class($firstElement)) {

					throw new HtmlFormException(sprintf("Class mismatch of form elements array. Expected '%s', found '%s'.", get_class($firstElement), get_class($e)));

				}
				
				// check whether names of element arrays match

				$nameToCheck = preg_replace('~\[\w*\]$~i', '', $e->getName());

				if($nameToCheck && $nameToCheck !== $name) {
					
					throw new HtmlFormException(sprintf("Name mismatch of form elements array. Expected '%s' or empty name, found '%s'.", $name, $e->getName()));

				}

				$e
					->setName($arrayName)
					->setForm($this)
				;

				$this->elements[$name][] = $e;
			}

		}

		return $this;

	}
1338368
private function elementAttr(string $element) : string
    {
        if (in_array($element, $this->elements) === true) {
            $attr = '';

            if (count($this->attr[$element]) > 0) {
                $attr = ' style="' . implode(' ', $this->attr[$element]) . '"';
            }

            return $attr;
        } else {
            return '';
        }
    }
940575
protected function searchAndReplacePlaceHolders(array $element, array $placeHolders)
    {
        array_walk_recursive($element, function(&$v, $k, $ph){
            if (is_string($v) && array_key_exists($v, $ph)) {
                $v = $ph[$v];
            }
        }, $placeHolders);
        return $element;
    }
972640
public function onReplaceInsertTags(string $tag)
    {
        $elements = explode('::', $tag);
        $key = strtolower($elements[0]);
        $attributes = \array_slice($elements, 1);

        if (\in_array($key, $this->supportedTags)) {
            return $this->replaceSupportedTags($key, $attributes);
        }

        return false;
    }
530657
public static function removeElementFromArray($elements, $array)
    {
        if (is_array($elements) && is_array($array))
        {
            foreach ($elements as $element)
            {
                if (in_array($element, $array))
                {
                    $key = array_search($element, $array);
                    unset($array[$key]);
                }
            }
        }
        return $array;
    }
48646
private function replace($bindings)
    {
        $search = array_keys($bindings);
        $replace = array_values($bindings);

        foreach ($search as $key => &$value) {
            $value = $this->delimiters[0].$value.$this->delimiters[1];
        }

        array_walk_recursive($this->rules, function(&$value, $key) use($search, $replace) {
            $value = str_ireplace($search, $replace, $value);
        });
    }
1324528
private function parseElement(array $element)
    {
        $elementXml = $this->dom->createElement('xsd:element');
        foreach ($element as $key => $value) {
            if (in_array($key, array('sequence', 'all', 'choice'))) {
                if (is_array($value)) {
                    $complexType = $this->dom->createElement('xsd:complexType');
                    if (count($value) > 0) {
                        $container = $this->dom->createElement('xsd:' . $key);
                        foreach ($value as $subElement) {
                            $subElementXml = $this->parseElement($subElement);
                            $container->appendChild($subElementXml);
                        }

                        $complexType->appendChild($container);
                    }

                    $elementXml->appendChild($complexType);
                }
            } else {
                $elementXml->setAttribute($key, $value);
            }
        }

        return $elementXml;
    }
1069553
protected function _replaceTags($matches)
    {
        $style = $this->styles($matches['tag']);
        if (empty($style)) {
            return '<' . $matches['tag'] . '>' . $matches['text'] . '</' . $matches['tag'] . '>';
        }

        $styleInfo = [];
        if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) {
            $styleInfo[] = static::$_foregroundColors[$style['text']];
        }
        if (!empty($style['background']) && isset(static::$_backgroundColors[$style['background']])) {
            $styleInfo[] = static::$_backgroundColors[$style['background']];
        }
        unset($style['text'], $style['background']);
        foreach ($style as $option => $value) {
            if ($value) {
                $styleInfo[] = static::$_options[$option];
            }
        }

        return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m";
    }
277719
public function replaceMeta(array $strings)
	{
		foreach ($strings as &$string)
		{
			foreach ($string as &$value)
			{
				if (isset($this->meta[$value]))
				{
					$value = $this->meta[$value];
				}
			}
		}

		return $strings;
	}
990129
protected function replace($data, $replacements = null)
    {
        if (!is_array($data) && !is_string($data)) {
            return $data;
        }

        if (!$replacements) {
            $replacements = $this->replacements();
            if (!$replacements) {
                return $data;
            }
        }

        if (is_array($data)) {
            foreach ($data as $key => &$value) {
                $value = $this->replace($value, $replacements);
            }
            return $data;
        }

        return str_replace(array_keys($replacements), array_values($replacements), $data);
    }
152265
public function replace($tags)
    {
        foreach ($tags as $tag) {
            if (!$tag instanceof Tag) {
                throw InvalidTagException::build([], ['invalidTag' => $tag]);
            }
        }

        parent::replace($tags);
    }