Converts a CSS string into a nested map of values.
See LuminousCSSParser::rules() for the structure.
@param $string the CSS string
@returns the rule map
777474
public function convert($string)
    {
        $css = self::parse($string);
        $data = self::formatCssArray($css);
        $this->data = $data;
        return $data;
    }
1206125
public static function parseRgbString(string $string) : array
    {
        if (!preg_match(self::REGEX_RGB, $string, $matches)) {
            throw InvalidArgumentException::format(
                    'Invalid rgb string passed to %s: expecting format "rgb(0-255, 0-255, 0-255)", "%s" given',
                    __METHOD__, $string
            );
        }

        return [(int)$matches[1], (int)$matches[2], (int)$matches[3]];
    }
1232448
public function parse($string)
    {
        $hashModes = [];

        foreach($this->hashLibrary as $hash){
            if(preg_match('/'.$hash['regex'].'/i', $string)) {
                foreach($hash['modes'] as $mode) {
                    $hashModes[] = new HashMode([
                        'name' => $mode['name'],
                        'hashcat' => $mode['hashcat'],
                        'john' => $mode['john'],
                        'extended' => $mode['extended'],
                    ]);
                }
            }
        }

        $this->modes = $hashModes;
        return $this;
    }
531778
public function formatPlain($string) {
        $groups = $this->formatParser->parseFormat($string);

        foreach ($groups as $group) {
            $tag = $group[0];
            $styleName = $group[1];

            if ($styleName === 'style' || $this->hasStyle($styleName)) {
                $string = str_replace($tag, '', $string);
            }
        }

        $string = $this->formatParser->unescapeTags($string);

        return $string;
    }
310008
protected function inflect($string)
    {
        if (null === $this->inflector) {
            return $string;
        }

        return call_user_func($this->inflector, $string);
    }
95645
public static function fromString( $string ) {
		$values = [
			'1'     => true,
			'y'     => true,
			'yes'   => true,
			'true'  => true,

			'0'     => false,
			'n'     => false,
			'no'    => false,
			'false' => false,
		];

		foreach ( $values as $value => $boolean ) {
			if ( strtolower( $value ) === strtolower( $string ) ) {
				return $boolean;
			}
		}

		// rely on PHP's string to boolean conversion in all other cases
		return (bool) $string;
	}
1291231
public function tokenize($string)
    {
        $matches = array();
        $count = preg_match_all($this->pattern, $string, $matches, $this->flags, $this->offset);
        if($count === false) { 
            return array();
        }
        return $matches[0];
        
    }
483704
public function format($string) {
        if ($this->isAnsiEnabled()) {
            return $this->formatAnsi($string);
        }

        return $this->formatPlain($string);
    }
549480
private function getStringToCamelCase( $string )
	{
		$words = preg_split( "#[^a-z0-9]#i", $string );
		$words = array_map( 'ucfirst', $words );

		return join( '', $words );
	}
201631
protected function parse_vars($string)
	{
		foreach ($this->vars as $var => $val)
		{
			$string = str_replace("%$var%", $val, $string);
		}

		return $string;
	}
1355771
private static function parseline($string){
        $string = str_replace(chr(10), "\\n", $string);
        $string = str_replace(chr(13), "\\n", $string);
        $string = str_replace("\f", "\\f", $string);
        return $string;
    }
124180
public static function parseStyles($string)
    {
        $styles = array();
        if (empty($string)) {
            return $styles;
        }

        $declarations = preg_split('/\s*;\s*/', $string);

        foreach ($declarations as $declaration) {
            $declaration = trim($declaration);
            if ($declaration === '') {
                continue;
            }
            $split             = preg_split('/\s*:\s*/', $declaration);
            $styles[$split[0]] = $split[1];
        }

        return $styles;
    }
1121268
public function parseString($string)
    {
        $value = $this->getParser()->parse($string);

        if ($this->trimArrayValues && is_array($value)) {
            return $this->trimArray($value);
        }

        return $value;
    }
335810
public function nlToPbr($string)
	{
		$string = trim($string);
		$string = Modifiers::linebreaks($string);
		$string = str_replace("\n", '<br />', $string);
		$string = str_replace('<br /><br />', "</p>\n<p>", $string);
		$string = str_replace('<p></p>', '', $string);
		return '<p>' . $string . '</p>' . PHP_EOL;
	}
415874
protected function convertToStringOrBoolean($string)
    {
        $result = (string) $string;
        $lowerString = strtolower($result);

        if('true' === $lowerString)
        {
            $result = true;
        }
        elseif('false' === $lowerString)
        {
            $result = false;
        }

        return $result;
    }
330629
public static function style($string, $style)
    {
        $escapeSequence = ($style instanceof Style) ? $style->getEscapeSequence() : self::getEscapeSequence($style);
        $resetSequence = ($style instanceof Style) ? Style::getResetSequence() : self::getResetSequence($style);

        return $escapeSequence . $string . $resetSequence;
    }
1144065
public function transform($string, array $ruleNames = array())
    {
        $rules = $this->getRules();

        foreach ($ruleNames ?: array_keys($rules) as $ruleName) {
            if (!isset($rules[$ruleName])) {
                // Just continue on unknown rules, or should we throw an error
                // here?
                continue;
            }

            foreach ($rules[$ruleName] as $rule) {
                $string = preg_replace_callback(
                    $rule['regexp'],
                    $rule['callback'],
                    $string
                );
            }
        }

        return $string;
    }