Detect most frequently used end of line sequence.

@param  string $content The content to detect the eol in.

@return string
503408
private function detectEol($content)
    {
        $maxCount = 0;
        $preferredEol = $this->preferredEol;
        $eols = ["\n", "\r", "\n\r", "\r\n"];

        foreach ($eols as $eol) {
            if (($count = substr_count($content, $eol)) >= $maxCount) {
                $maxCount = $count;
                $preferredEol = $eol;
            }
        }

        $this->preferredEol = $preferredEol;

        return $preferredEol;
    }
1184126
public function label($content)
    {
        // Handle long labels by splitting them across several lines
        $lines = [];
        $stop = mb_strlen($content);
        $width = $this->util->width();
        for ($i = 0; $i < $stop; $i += $width) {
            $lines[] = mb_substr($content, $i, $width);
        }
        $content = array_pop($lines);

        foreach ($lines as $line) {
            $this->output->write($this->parser->apply($line));
        }

        $content = $this->padContent($content);
        $content = $this->parser->apply($content);

        $this->output->sameLine();
        $this->output->write($content);

        return $this;
    }
1005855
public static function markupToPHP($content) 
    {
        if ($content instanceof phpQueryObject) {
            $content = $content->markupOuter();
        }
        /* <php>...</php> to <?php...? > */
        $content = preg_replace_callback(
            '@<php>\s*<!--(.*?)-->\s*</php>@s',
            //            create_function('$m',
            //                'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";'
            //            ),
            array('phpQuery', '_markupToPHPCallback'),
            $content
        );
        /* <node attr='< ?php ? >'> extra space added to save highlighters */
        $regexes = array(
        '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^\']*)\'@s',
        '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^"]*)"@s',
        );
        foreach($regexes as $regex) {
            while (preg_match($regex, $content)) {
                $content = preg_replace_callback(
                    $regex,
                    create_function(
                        '$m',
                        'return $m[1].$m[2].$m[3]."<?php "
							.str_replace(
								array("%20", "%3E", "%09", "&#10;", "&#9;", "%7B", "%24", "%7D", "%22", "%5B", "%5D"),
								array(" ", ">", "	", "\n", "	", "{", "$", "}", \'"\', "[", "]"),
								htmlspecialchars_decode($m[4])
							)
							." ?>".$m[5].$m[2];'
                    ),
                    $content
                );
            }
        }
        return $content;
    }
1134326
private function clean($content)
    {
        // line feed
        $content = str_replace("\r\n", "\n", $content);
     
        // trailing whitespaces
        $content = preg_replace('/[ \t]*$/m', '', $content);

        // indentation
        $content = preg_replace_callback('/^([ \t]+)/m', function ($matches) use ($content) {
            return str_replace("\t", '    ', $matches[0]);
        }, $content);

        // Unused "use" statements
        preg_match_all('/^use (?P<class>[^\s;]+)(?:\s+as\s+(?P<alias>.*))?;/m', $content, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            if (isset($match['alias'])) {
                $short = $match['alias'];
            } else {
                $parts = explode('\\', $match['class']);
                $short = array_pop($parts);
            }

            preg_match_all('/\b'.$short.'\b/i', str_replace($match[0]."\n", '', $content), $m);
            if (!count($m[0])) {
                $content = str_replace($match[0]."\n", '', $content);
            }
        }

        // end of line
        if (strlen($content) && "\n" != substr($content, -1)) {
            $content = $content."\n";
        }

        return $content;
    }
869985
public function get_content_length($content)
	{
		$content = $this->restore_square_brackets_in_smilies($content);

		$content_length = utf8_strlen($content);
		$last_smiley = false;
		$last_html_closing = 0;
		while (($last_html_opening = utf8_strpos($content, '<', $last_html_closing)) !== false)
		{
			$last_html_closing = utf8_strpos($content, '>', $last_html_opening);
			if (($smiley_code = utf8_substr($content, $last_html_opening + 6, ($last_html_closing - $last_html_opening - 9))) != '--')
			{
				if ($last_smiley == $smiley_code)
				{
					$content_length += utf8_strlen($smiley_code);
					$last_smiley = false;
				}
				else
				{
					$last_smiley = $smiley_code;
				}
			}
			$content_length -= ($last_html_closing - $last_html_opening) + 1;
		}
		return $content_length;
	}
896153
public static function countLinesFromSource( $content )
	{
		$counter		= 0;
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberStrips	= 0;
		$linesCodes		= array();
		$linesDocs		= array();
		$linesStrips	= array();

		$lines		= explode( "\n", $content );
		foreach( $lines as $line )
		{
			if( preg_match( "@^(\t| )*/?\*@", $line ) )
			{
				$linesDocs[$counter] = $line;
				$numberDocs++;
			}
			else if( preg_match( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else if( preg_match( "@^(public|protected|private|class|function|final|define|import)@", trim( $line ) ) )
			{
				$linesStrips[$counter] = $line;
				$numberStrips++;
			}
			else
			{
				$linesCodes[$counter] = $line;
				$numberCodes++;
			}
			$counter ++;
		}
		$data	= array(
			'length'		=> strlen( $content ),
			'numberCodes'	=> $numberCodes,
			'numberDocs'	=> $numberDocs,
			'numberStrips'	=> $numberStrips,
			'linesTotal'	=> $counter,
			'linesCodes'	=> $linesCodes,
			'linesDocs'		=> $linesDocs,
			'linesStrips'	=> $linesStrips,
			'ratioCodes'	=> $numberCodes / $counter * 100,
			'ratioDocs'		=> $numberDocs / $counter * 100,
			'ratioStrips'	=> $numberStrips / $counter * 100,
		);
		return $data;
	}
1089875
public function closure($content = null)
    {
        $this->addNewToSequence("open");

        if (!empty($content)) {
            if ($content instanceof TokenSequencer) {
                $this->mergeSequence($content->getSequence());
            } elseif ($content instanceOf Token) {
                $this->addToSequence($content);
            } elseif (is_array($content)) {
                foreach ($content as $subContent) {
                    $this->addMixedContentToSequence($subContent);
                }
            } else {
                $this->val($content);
            }
        }

        $this->addNewToSequence("close");

        return $this;
    }
1272176
public function parse($content)
	{
		$log = new Log;
		$description = [];
		$links = [];
		$matches = [];
		$bodyEnded = false;

		$line = current($content);
		while ($line !== false)
		{
			$line = ltrim($line);

			if (preg_match('/^#(?!#).+/', $line) === 1)
			{
				$log->setTitle($this->trimHashes($line));
			}
			elseif (preg_match('/^##(?!#).+/', $line) === 1)
			{
				$release = $this->parseRelease($content);
				$log->addRelease($release);
				$bodyEnded = true;
			}
			elseif (preg_match('/^\[(.+)\]: (.+)/', $line, $matches))
			{
				if (count($matches) >= 3)
				{
					$links[$matches[1]] = $matches[2];
				}
				$bodyEnded = true;
			}
			elseif ( ! $bodyEnded)
			{
				$description[] = $line;
			}

			$line = next($content);
		}

		$log->setDescription(implode("\n", $description));

		// Assign the releases their real links
		$this->assignLinks($log, $links);

		return $log;
	}
755869
public function parseLogBody($content)
    {
        $pattern      = "/^".self::STACK_TRACE_DIVIDER_PATTERN."/m";
        $parts        = array_map('ltrim', preg_split($pattern, $content));
        $context      = $parts[0];
        $stack_traces = (isset($parts[1])) ? $parts[1] : null;

        return compact('context', 'stack_traces');
    }
465592
function endnoteShortcode( $atts, $content = null ) {

		global $id; // This is the Post ID, [@see WP_Query::setup_postdata, preProcessBookContents, ...]

		if ( ! $content ) {
			return '';
		}

		$this->endnotes[ $id ][] = trim( $content );

		return '<sup class="endnote">' . count( $this->endnotes[ $id ] ) . '</sup>';
	}
13362
protected function _censor($content) {
        $pattern = implode('|', array_map(array($this, '_prepareRegex'), $this->getBlacklist()));
        $content = preg_replace_callback('/(?:^|\b)(?:' . $pattern . ')(?:\b|$)/is', array($this, '_censorCallback'), $content);

        return $content;
    }
1034487
protected function padContent($content)
    {
        if (strlen($this->char) > 0) {
            $length = $this->getLength();
            $padding_length = ceil($length / mb_strlen($this->char));

            $padding = str_repeat($this->char, $padding_length);
            $content .= mb_substr($padding, 0, $length - mb_strlen($content));
        }

        return $content;
    }
1277786
protected function correct($content)
    {
        $corrections = $this->corrections;
        if (!empty($corrections)) {
            foreach ($corrections as $pattern => $replacement) {
                $reg_count = 0;

                /**
                 * @var $content
                 * reassign $content to corrected $content as long as corrections
                 * rules array loop
                 */
                $content = preg_replace('/' .
                    $pattern .
                    '/us', $replacement, $content, -1, $reg_count);
            }
        }
        return $content;
    }
1260616
public function parse($content)
    {
        $set = null;
        if (strpos($content, '@ORM') === false) {
            return $set;
        }

        if (preg_match(self::PATTERN, $content, $matches)) {
            $set[] = [$matches[1], $matches[2]];
        }



        return $set;
    }
601437
public function getBetween($content, $start, $end = null)
    {
        return $this->api->getBetween($content, $start, $end);
    }
806412
private function detectFormatByContent($content)
    {
        if (preg_match('/^\\{.*\\}$/is', $content)) {
            return self::FORMAT_JSON;
        }
        if (preg_match('/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/', $content)) {
            return self::FORMAT_URLENCODED;
        }
        if (preg_match('/^<.*>$/s', $content)) {
            return self::FORMAT_XML;
        }
    }
512967
public function humanReadingTime($content)
    {
        if (empty($content)) {
            return '';
        }
        $content = StringHelper::stripHtml($content);
        $seconds = $this->readingTime($content);

        return Craft::$app->formatter->asDuration($seconds);
    }