<commit_before><?php
App::uses('AppHelper', 'View/Helper');

    // prepend user names on the header with some text based on the given rules
    class ScopedCSSHelper extends AppHelper {

        private function endsWith($haystack, $needle)
        {
            $length = strlen($needle);
            if ($length == 0) {
                return true;
            }
            return (substr($haystack, -$length) === $needle);
        }

        private function preppendScopedId($css, $seed)
        {
            $prependSelector = sprintf('[data-scoped="%s"]', $seed);
            $cssLines = explode("\n", $css);
            foreach ($cssLines as $i => $line) {
                if (strlen($line) > 0) {
                    if ($this->endsWith($line, "{") || $this->endsWith($line, ",")) {
                        $cssLines[$i] = sprintf("%s %s", $prependSelector, $line);
                    }
                }
            }
            $cssScopedLines = implode(PHP_EOL, $cssLines);
            return sprintf("<style>%s%s%s</style>", PHP_EOL, $cssScopedLines, PHP_EOL);
        }


         /**
         * Replace a declared CSS scoped style and prepend a random CSS data filter to any CSS selector discovered.
         * Usage: Add the following style tag `<style widget-scoped>` to use the scoped feature. Nearly every selector path will have their rule modified to adhere to the scope
         * Restrictions:
         *      - Applying class to the root document (i.e. `body`) will not work
         *      - Selector rules must end with either `{` or `,`, their content MUST be put in a new line:
         *          [bad]
         *              element { ... }
         *          [good] 
         *              element {
         *                  ...
         *              }
         *      - Selectors with the `and` (`,`) rule MUST be split in multiple lines:
         *          [bad]
         *              element,element {
         *                  ...
         *              }<commit_msg>chg: [helper:ScopedCSS] Usage of PHP_EOL<commit_after><?php
App::uses('AppHelper', 'View/Helper');

    // prepend user names on the header with some text based on the given rules
    class ScopedCSSHelper extends AppHelper {

        private function endsWith($haystack, $needle)
        {
            $length = strlen($needle);
            if ($length == 0) {
                return true;
            }
            return (substr($haystack, -$length) === $needle);
        }

        private function preppendScopedId($css, $seed)
        {
            $prependSelector = sprintf('[data-scoped="%s"]', $seed);
            $cssLines = explode(PHP_EOL, $css);
            foreach ($cssLines as $i => $line) {
                if (strlen($line) > 0) {
                    if ($this->endsWith($line, "{") || $this->endsWith($line, ",")) {
                        $cssLines[$i] = sprintf("%s %s", $prependSelector, $line);
                    }
                }
            }
            $cssScopedLines = implode(PHP_EOL, $cssLines);
            return sprintf("<style>%s%s%s</style>", PHP_EOL, $cssScopedLines, PHP_EOL);
        }


         /**
         * Replace a declared CSS scoped style and prepend a random CSS data filter to any CSS selector discovered.
         * Usage: Add the following style tag `<style widget-scoped>` to use the scoped feature. Nearly every selector path will have their rule modified to adhere to the scope
         * Restrictions:
         *      - Applying class to the root document (i.e. `body`) will not work
         *      - Selector rules must end with either `{` or `,`, their content MUST be put in a new line:
         *          [bad]
         *              element { ... }
         *          [good] 
         *              element {
         *                  ...
         *              }
         *      - Selectors with the `and` (`,`) rule MUST be split in multiple lines:
         *          [bad]
         *              element,element {
         *                  ...
         *              }
{'fraction_non_alphanumeric': 0.12014742014742015, 'fraction_numerical': 0.0009828009828009828, 'mean_word_length': 1.4406474820143884, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2213509', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1063, 'n_words': 324}