Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Common.php

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

Common

Namespace

PHP_CodeSniffer\Util

Code

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;
}
RSS feed
Powered by Drupal