function Common::detectLineEndings
Detects the EOL character being used in a string.
Parameters
string $contents The contents to check.:
Return value
string
1 call to Common::detectLineEndings()
- File::setContent in vendor/
squizlabs/ php_codesniffer/ src/ Files/ File.php - Set the content of the file.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Util/ Common.php, line 172
Class
Namespace
PHP_CodeSniffer\UtilCode
public static function detectLineEndings($contents) {
if (preg_match("/\r\n?|\n/", $contents, $matches) !== 1) {
// Assume there are no newlines.
$eolChar = "\n";
}
else {
$eolChar = $matches[0];
}
return $eolChar;
}