@param string $contents

@return string
182396
public function restorePlaceholders($contents)
    {
        foreach ($this->all() as $placeholder => $original) {
            $contents = str_replace($placeholder, $original, $contents);
        }

        return $contents;
    }
1294633
public static function get_content_value($content) {
        $arr = explode('##', $content->content);

        $strvalue = '';
        foreach ($arr as $a) {
            $strvalue .= $a . ' ';
        }

        return trim($strvalue, "\r\n ");
    }
1311727
static function UTF8ToHTML($content="")
	{
		$contents = self::unicode_string_to_array($content);
		$swap = "";
		$iCount = count($contents);
		for ($o=0;$o<$iCount;$o++) {
			$contents[$o] = self::unicode_entity_replace($contents[$o]);
			$swap .= $contents[$o];
		}
		return mb_convert_encoding($swap,"UTF-8"); //not really necessary, but why not.
	}
820346
public function getDescendantsContentUids($contents)
    {
        if (false === is_array($contents)) {
            $contents = array($contents);
        }

        $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');

        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('c.'.$meta->getColumnName('subcontent_uid'))
                ->from($meta->getTableName(), 'c');

        $index = 0;
        $atleastone = false;
        foreach ($contents as $content) {
            if (false === ($content instanceof AbstractClassContent)) {
                continue;
            }

            if (true === $content->isElementContent()) {
                continue;
            }

            $q->orWhere('c.'.$meta->getColumnName('content_uid').' = :uid'.$index)
                    ->setParameter('uid'.$index, $content->getUid());

            $index++;
            $atleastone = true;
        }

        return (true === $atleastone) ? array_unique($q->execute()->fetchAll(\PDO::FETCH_COLUMN)) : array();
    }
1218882
private function lex(string $contents): array
    {
        $contents = $this->removeSuperfluousStartingWhitespace($contents);

        // performance optimalization; if there is no inline tag, don't bother splitting it up.
        if (strpos($contents, '{@') === false) {
            return [$contents];
        }

        return preg_split(
            '/\{
                # "{@}" is not a valid inline tag. This ensures that we do not treat it as one, but treat it literally.
                (?!@\})
                # We want to capture the whole tag line, but without the inline tag delimiters.
                (\@
                    # Match everything up to the next delimiter.
                    [^{}]*
                    # Nested inline tag content should not be captured, or it will appear in the result separately.
                    (?:
                        # Match nested inline tags.
                        (?:
                            # Because we did not catch the tag delimiters earlier, we must be explicit with them here.
                            # Notice that this also matches "{}", as a way to later introduce it as an escape sequence.
                            \{(?1)?\}
                            |
                            # Make sure we match hanging "{".
                            \{
                        )
                        # Match content after the nested inline tag.
                        [^{}]*
                    )* # If there are more inline tags, match them as well. We use "*" since there may not be any
                       # nested inline tags.
                )
            \}/Sux',
            $contents,
            0,
            PREG_SPLIT_DELIM_CAPTURE
        );
    }
403985
protected function removeElement($element, $contents)
    {
        $newContents = preg_replace('@'.$element->regex.'@xi', '', $contents);

        if ($newContents !== $contents && isset($element->elements)) {
            foreach ($element->elements as $element) {
                $newContents = $this->removeElement($element, $newContents);
            }
        }

        return $newContents;
    }
806561
public function addContents($contents)
    {
        if (current($contents) instanceof Content) {
            foreach ($contents as $content) {
                $this->addContent($content);
            }
        } else {
            foreach ($contents as $key => $value) {
                $this->addContent($key, $value);
            }
        }
    }
931948
public function contentParser($content)
    {
        return str_replace(['{{dataApiUrl}}', '{{title}}', '{{template}}'], [$this->getDataApiUrl(), $this->getTitle(), $this->_template], $content);
    }
619785
private function getTokenisedContent(string $content)
    {

        $tokens = token_get_all($content);


        $tokenised_content = array();
        $tokenised_content = $this->addToken($tokenised_content, $tokens, $content);

        return $tokenised_content;

    }
1320501
public function replace($contents, array $variables = [], array $replacements = [])
    {
        $contents = str_replace($variables, $replacements, $contents);
        $contents = preg_replace('/^ +$/m', '', $contents);

        return $contents;
    }
749844
public static function getIndent($content)
    {
        $indent = self::DEFAULT_INDENT;
        preg_match(self::INDENT_REGEX, trim($content), $matches);

        if (!empty($matches)) {
            $indent = \strlen($matches[1]);
        }

        return $indent;
    }
1049739
protected function preprocessWindowsPaths($contents)
    {
        $expression = "/'([A-Za-z]:)?((\\\\|\/)[^\\/:*?\"\'<>|\r\n]*)*'/";

        $paths = array();
        preg_match_all($expression, $contents, $paths);

        $modified = $contents;
        foreach ($paths[0] as $path) {
            $normalizedPath = str_replace('\\\\', '/', $path);
            $modified = str_replace($path, $normalizedPath, $modified);
        }

        if ($contents !== $modified) {
            $this->myCommand->info('Preprocessed windows paths in "bootstrap/cache/config.php".');
        }

        return $modified;
    }
356338
protected function saveContents($contents)
    {
        $this->contents = $contents;

        try {
            $this->getFilesystem()->put($this->getFilepath(), json_encode($contents));
        } catch (Exception $e) {
            // ...
        }
    }
289469
protected function export_format($contents)
	{
		if ( ! function_exists('spyc_load'))
		{
			import('spyc/spyc', 'vendor');
		}

		$this->prep_vars($contents);
		return \Spyc::YAMLDump($contents);
	}
921173
public function runMinificationRules($contents)
    {
        do {
            $originalContents = $contents;
            $contents = preg_replace(array_keys($this->minifyRules), array_values($this->minifyRules), $contents);
        } while ($originalContents != $contents);

        return $contents;
    }
1347337
protected function export_format($contents)
	{
		$this->prep_vars($contents);
		return \Format::forge()->to_json($contents, true);
	}
493396
public function prepareContent($content)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            return $cto->prepareContent($content);
        } else {
            return (string) $content;
        }
    }