Creates an RDF Node based on a N-Triples/N-Quads node string.

@param $string string the N-Triples/N-Quads node string

@return Node

@throws \Exception if no node could be created e.g. because of a syntax error in the node string
487005
public function createNodeFromNQuads($string)
    {
        $regex = '/'.$this->getRegexStringForNodeRecognition(
            true, true, true, true, true, true
        ).'/si';

        $string = trim($string);

        preg_match($regex, $string, $matches);

        if (0 == count($matches)) {
            throw new \Exception('Invalid parameter $string given. Our regex '.$regex.' doesnt apply.');
        }

        $firstChar = substr($matches[0], 0, 1);

        // http://...
        if ('<' == $firstChar) {
            return $this->createNamedNode(str_replace(['<', '>'], '', $matches[1]));
        // ".."^^<
        } elseif (false !== strpos($matches[0], '"^^<')) {
            return $this->createLiteral($matches[9], $matches[10]);
        // "foo"@en
        } elseif (false !== strpos($matches[0], '"@')) {
            return $this->createLiteral($matches[12], null, $matches[13]);
        // "foo"
        } elseif ('"' == $firstChar) {
            return $this->createLiteral($matches[15]);
        // _:foo
        } elseif ($this->simpleCheckBlankNodeId($matches[0])) {
            return $this->createBlankNode($matches[4]);
        // 0-9 (simple number, multi digits)
        } elseif (0 < (int) $matches[0]) {
            return $this->createLiteral(
                $matches[16],
                $this->createNamedNode('http://www.w3.org/2001/XMLSchema#double')
            );
        } else {
            throw new \Exception('Unknown case for: '.$matches[1]);
        }
        throw new \Exception("The given string (\"$string\") is not valid or doesn't represent any RDF node");
    }
1271726
public static function create($string): self
    {
        if ($string instanceof self) {
            return $string;
        }

        if (empty($string)) {
            throw new \InvalidArgumentException(
                    'Given string was null or empty, if you explicitly want to'
                    . ' create a Secret with value null use'
                    . ' Secret::forNull()'
            );
        }

        $self = new static();
        try {
            $encrypt = self::$encrypt;
            self::$store[$self->id] = ['payload' => $encrypt($string),
                                       'length'  => \iconv_strlen($string)
                                      ];
        } catch (\Throwable $t) {
            $t = null;
            // This intentionally catches *ALL* exceptions, in order not to fail
            // and produce a stacktrace containing arguments on the stack that
            // were supposed to be protected.
            unset(self::$store[$self->id]);
        }

        $string = str_repeat('*', strlen($string));
        $string = null;
        return $self;
    }
618379
static function fromString(string $string): self
    {
        $string = str_replace("/", "\\", $string);
        $string = preg_replace("#(\\\\){2,}#", "\\", $string);
        if (substr($string, -1, 1) == "\\") {
            $string = substr($string, 0, -1);
        }
        
        return new self($string);
    }
761612
public static function fromString(string $string): self
    {
        $string = new Str($string);
        $pattern = sprintf(
            '~%s/[\w\-.]+(\+\w+)?([;,] [\w\-.]+=[\w\-.]+)?~',
            self::topLevels()->join('|')
        );

        if (!$string->matches($pattern)) {
            throw new InvalidMediaTypeString;
        }

        $splits = $string->pregSplit('~[;,] ?~');
        $matches = $splits
            ->get(0)
            ->capture(sprintf(
                '~^(?<topLevel>%s)/(?<subType>[\w\-.]+)(\+(?<suffix>\w+))?$~',
                self::topLevels()->join('|')
            ));

        $topLevel = $matches->get('topLevel');
        $subType = $matches->get('subType');
        $suffix = $matches->contains('suffix') ? $matches->get('suffix') : '';
        $params = new Map('string', Parameter::class);

        $splits
            ->drop(1)
            ->foreach(function(Str $param) use (&$params) {
                $matches = $param->capture(
                    '~^(?<key>[\w\-.]+)=(?<value>[\w\-.]+)$~'
                );

                $params = $params->put(
                    (string) $matches->get('key'),
                    new Parameter\Parameter(
                        (string) $matches->get('key'),
                        (string) $matches->get('value')
                    )
                );
            });

        return new self(
            (string) $topLevel,
            (string) $subType,
            (string) $suffix,
            $params
        );
    }
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;
    }
862035
public static function createFromString($string) {
        list($latitude, $longitude) = explode(',', $string);
        return new static(new Coordinate($latitude), new Coordinate($longitude));
    }
922329
public static function fromString($string)
    {
        $parts = explode(':', $string, 3);
        Assertion::count($parts, 3, 'NodeRef format must be "vendor:label:id');
        $id = array_pop($parts);
        $qname = SchemaQName::fromString(implode(':', $parts));
        return new self($qname, $id);
    }
393513
protected function replaceChild($string)
    {
        if (!empty($string)) {
            $newDocument = new Document($string);

            if ($newDocument->outertext !== $string) {
                throw new RuntimeException('Not valid HTML fragment');
            }
        }

        foreach ($this->node->childNodes as $node) {
            $this->node->removeChild($node);
        }

        if (!empty($string)) {
            $newNode = $this->node->ownerDocument->importNode($newDocument->getDocument()->documentElement, true);
            $this->node->appendChild($newNode);
        }

        return $this;
    }
1359417
public function append(string $string): self
    {
        return new self((string) $this.$string, $this->encoding);
    }
1186778
public static function smartExplode($string)
    {
        if (empty($string))
            return array();

        if (is_array($string))
            return $string;

        if (!is_array($string)) {
            if (strpos($string, ';') !== false)
                return explode(';', trim($string, ';'));

            if (strpos($string, ',') !== false)
                return explode(',', trim($string, ','));
        }

        return (array)$string;
    }
920100
public function writeString(&$string)
    {
        $len = strlen($string);
        if(!$len){
            $this->writeInteger(0x01);
            return $this;
        }

        $ref = array_key_exists($string, $this->_referenceStrings) 
             ? $this->_referenceStrings[$string] 
             : false;
        if ($ref === false){
            $this->_referenceStrings[$string] = count($this->_referenceStrings);
            $this->writeBinaryString($string);
        } else {
            $ref <<= 1;
            $this->writeInteger($ref);
        }

        return $this;
    }
138633
public static function fromString(string $string): self
    {
        if (1 !== \preg_match('/^(?>\r\n|\n|\r)$/', $string)) {
            throw Exception\InvalidNewLineStringException::fromString($string);
        }

        return new self($string);
    }
258905
public static function createFromCamel($string, $allowSlashes = false)
    {
        $string = trim(preg_replace('/(([A-Z]|[0-9])[^A-Z])/', ' $1', $string));
        return self::create($string, $allowSlashes);
    }
1126215
public static function fromString($string)
	{
		$bits = new BitArray(strlen($string));
		$ord = 0;

		for ($offset = 0; $offset < $bits->size; $offset++)
		{
			if ($string[$offset] !== '0')
			{
				$ord |= 1 << $offset % 8;
			}

			if ($offset % 8 === 7)
			{
				$bits->data[(int) ($offset / 8)] = chr($ord);
				$ord = 0;
			}
		}

		if ($offset % 8 !== 0)
		{
			$bits->data[(int) ($offset / 8)] = chr($ord);
		}

		return $bits;
	}
1196281
public static function fromString($string, $separator=' '){

        $string = (string)$string;

        if($separator === ''){
            return new StringList(str_split($string),'');
        }

        $prefix = '';
        $suffix = '';
        if($string[0] == $separator){
            $prefix = $separator;
        }
        if($string[strlen($string)-1] == $separator){
            $suffix = $separator;
        }
        $strList = new StringList(explode($separator,trim($string,$separator)),
                                          $separator);
        $strList->prefix = $prefix;
        $strList->suffix = $suffix;
        return $strList;
    }
1182536
static function parse_string( $s ){
		if( $s == '' ){
			throw new Exception('Cannot parse empty string');
		}
		// instantiate self
		$Parser = new BNFParser;
		// perform external tokenizing on string input 
		$tokens = bnf_tokenize( $s );
		return $Parser->parse( $tokens );
	}
1273398
protected function replaceText($string)
    {
        if (empty($string)) {
            $this->node->parentNode->removeChild($this->node);

            return null;
        }

        $newElement = $this->node->ownerDocument->createTextNode($string);

        $newNode = $this->node->ownerDocument->importNode($newElement, true);

        $this->node->parentNode->replaceChild($newNode, $this->node);
        $this->node = $newNode;

        return $this;
    }