Factory function

@param string $string A comma-delimited list of key:value pairs. Example: "min:0,max:10".
@return HTMLPurifier_AttrDef_Float
554627
public function make($string)
    {
        $options = array();
        foreach (explode(',', $string) as $pair) {
            $parts = explode(':', $pair, 2);
            if (count($parts) === 2) {
                list($key, $value) = $parts;
                $options[$key] = $value;
            }
        }
        $class = get_class($this);
        return new $class($options);
    }
1241671
public static function escape($string)
    {
        Arguments::define(
            Boa::either(
                Boa::either(
                    Boa::instance(SafeHtmlWrapper::class),
                    Boa::instance(SafeHtmlProducerInterface::class)
                ),
                Boa::string()
            )
        )->check($string);

        if ($string instanceof SafeHtmlWrapper) {
            return $string;
        } elseif ($string instanceof SafeHtmlProducerInterface) {
            $result = $string->getSafeHtml();

            if ($result instanceof SafeHtmlWrapper) {
                return $result;
            } elseif ($result instanceof SafeHtmlProducerInterface) {
                return static::escape($result);
            }

            throw new CoreException(vsprintf(
                'Object of class %s implements SafeHtmlProducerInterface'
                . ' but it returned an unsafe type: %s',
                [get_class($string), TypeHound::fetch($result)]
            ));
        }

        return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
    }
631804
public static function parse($string)
  {
    $attr = [];
    $list = [];

    preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);

    if ( is_array($attr) ){
      $numPairs = count($attr[1]);
      for ($i = 0; $i < $numPairs; $i++){
        $list[$attr[1][$i]] = $attr[2][$i];
      }
    }
    
    return $list;
  }
1243377
public static function fromString($string)
    {
        if (!preg_match(self::VALID_PATTERN, $string, $matches)) {
            throw new AssertionFailed(
                sprintf(
                    'AssetId [%s] is invalid.  It must match the pattern [%s].',
                    $string,
                    self::VALID_PATTERN
                ),
                Assertion::INVALID_REGEX,
                null,
                $string
            );
        }

        return new self($matches[1], $matches[2], $matches[3], $matches[4]);
    }
417984
public static function fromString($string)
    {
        \Assert\that($string)
            ->string('Argument has to be a string')
            ->uuid('String has to be an UUID');

        return new static(Uuid::fromString($string));
    }
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;
    }
236724
public function html($string)
    {
        if (!$string) {
            return $string;
        }

        $result = htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding);
        return $result;
    }
19790
private function createStyleFromString($string)
    {
        if (isset($this->styles[$string])) {
            return $this->styles[$string];
        }

        if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) {
            return false;
        }

        $style = new OutputFormatterStyle();
        foreach ($matches as $match) {
            array_shift($match);

            if ('fg' == $match[0]) {
                $style->setForeground($match[1]);
            } elseif ('bg' == $match[0]) {
                $style->setBackground($match[1]);
            } elseif ('options' === $match[0]) {
                preg_match_all('([^,;]+)', $match[1], $options);
                $options = array_shift($options);
                foreach ($options as $option) {
                    try {
                        $style->setOption($option);
                    } catch (\InvalidArgumentException $e) {
                        @trigger_error(sprintf('Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED);

                        return false;
                    }
                }
            } else {
                return false;
            }
        }

        return $style;
    }
133558
public static function createFromHtmlString($string)
    {
        self::$instance = new Collector;

        // Cria um arquivo temporário
        $temp_file = tempnam(sys_get_temp_dir(), uniqid('report-collection'));
        file_put_contents($temp_file, $string);

        // Carrega o arquivo na planilha
        self::$instance->createFromFile($temp_file, 'html');
        unlink($temp_file);

        self::$instance->debug_info = ['created_with' => __METHOD__];

        return self::$instance;
    }
1371793
public static function ordStr($string)
    {
        $codes = array();

        $encoding = mb_detect_encoding($string);
        $size = mb_strlen($string, $encoding);

        for ($i = 0; $i < $size; $i++) {
            $char = mb_substr($string, $i, 1, $encoding);
            $codes[] = static::ord($char);
        }

        return $codes;
    }
750115
public static function toRange($string)
    {
        if (null === $string) {
            return null;
        } elseif ('' === $string) {
            return [];
        }

        if (!strstr($string, '..')) {
            return [];
        }

        list($min, $max) = explode('..', $string, 2);
        if (null == $min || null == $max) {
            return [];
        }

        return range($min, $max);
    }
1310606
public static function minifyString( $string )
	{
		$string = str_replace( PHP_EOL , ' ' , $string );
		$string = preg_replace( '/[\r\n]+/' , "\n" , $string );

		return preg_replace( '/[ \t]+/' , ' ' , $string );
	}
269134
public function prepend($string)
	{
		ArgumentValidator::validateScalar($string);
		$this->string = (string)$string . $this->string;
		return $this;
	}
1220215
public static function stringToValueAndUnit(string $string): array
    {
        preg_match('/^([0-9.]+)([µa-zA-Z]+)$/', $string, $matches);
        $value = (float) $matches[1];
        $unit = Mapper::getUnitFromAbbreviation($matches[2]);
        return [$value, $unit];
    }
54483
public function hash($string)
	{
		// Format strength
		$strength = str_pad($this->strength, 2, '0', STR_PAD_LEFT);

		// Create salt
		$salt = $this->createSalt();

		//create prefix; $2y$ fixes blowfish weakness
		$prefix = PHP_VERSION_ID < 50307 ? '$2a$' : '$2y$';

		return crypt($string, $prefix.$strength.'$'.$salt.'$');
	}
1246804
public static function factory($modifyString)
    {
        $modifyString = explode(self::PARAM_SPLITTER, $modifyString);
        $modifier = '\\' . __NAMESPACE__ . '\\' . ucfirst($modifyString[0]);
        unset($modifyString[0]);
        return new $modifier(array_values($modifyString));
    }
955914
public function parse($string)
    {
        global $matchedNotes;

        $keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
        
        $data = array();
        $toDelete = [];
        $lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);

        foreach ($lines as list($l, $offset)) {
            $len = strlen($l);
            $l = trim($l);
            $offset += $len - strlen($l);

            if ($l && $l[0] == '@') {
                $curDelete = trim($l);
                $l = substr($l, 1);
                $d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
                
                $key = $d[0][0];
                if ($this->keyPrefix) {
                    if (strpos($key, $this->keyPrefix)!==0)
                        continue;
                    $key = substr($key, $keyPrefixLen);
                }
                
                $key = preg_split(
                    "/(
                           \]\[
                        |  \[
                        |  \]\.   # when php style abuts dot notation (foo[a].b)
                        |  \]
                        |  \.)
                    /x", 
                    rtrim($key, ']')
                );
                
                if (isset($d[1])) {
                    $value = $d[1][0];
                }
                else {
                    $value = $this->defaultValue;
                }
                
                $current = &$data;
                $found = array();
                foreach ($key as $part) {
                    if ($current && !is_array($current)) {
                        throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
                    }

                    if (!$found) {
                        if (in_array($part, $matchedNotes)) {
                            $toDelete[] = $curDelete;
                        }
                    }
                    
                    $found[] = $part;
                    
                    // if the last segment is empty, it means "@key[] value" or "@key. value" was used,
                    //  so we should just assign the next key
                    if ($part !== "")
                        $current = &$current[$part];
                    else
                        $current = &$current[];
                }
                
                if ($current === null)
                    $current = $value;
                elseif (!is_array($current))
                    $current = array($current, $value);
                else
                    $current[] = $value;
                
                unset($current);
            }
        }
        return [$data, $toDelete];
    }