Parses the string and returns the {@link Uri}.

Parses the string and returns the {@link Uri}. If parsing fails, null is returned.

@param String $string The url.

@return \Bumble\Uri\Uri The Uri object.
499451
public function parse( $string ) {
        $data = parse_url( $string );
        
        //helper function gets $a[$k], checks if exists
        function get( $a, $k ) {
            if( array_key_exists( $k, $a ) ) {
                return empty( $a[$k] ) ? null : $a[$k];
            }
            
            return null;
        }
        
        if( $data === null ) {
            return null;
        }
        
        $uri = new Uri;
        
        $uri->setProtocol( get( $data, 'scheme' ) );
        $uri->setUsername( get( $data, 'user' ) );
        $uri->setPassword( get( $data, 'pass' ) );
        $uri->setHost( get( $data, 'host' ) );
        $uri->setPort( get( $data, 'port' ) );
        $uri->setPath( get( $data, 'path' ) );
        $uri->setQuery( get( $data, 'query' ) );
        $uri->setAnchor( get( $data, 'anchor' ) );
        
        return $uri;
    }
784812
public function parseUrl($string)
    {
        $this->url = [];

        $url = parse_url($string);
        if (!$url || !isset($url['scheme'])) {
            throw new \Exception(sprintf('The url \'%s\' could not be parsed', $string));
        }

        $this->parseUrlArray($url);
    }
162895
public function parseString($string)
    {
        //argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        foreach ($this->data as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
1362804
public function getString($String)
    {
        if (isset($this->Data[$String])) {
            return $this->Data[$String];
        }
        return isset($this->Fallback[$String]) ? $this->Fallback[$String] : '';
    }
1080992
public function loadString($string)
    {
        $this->sourceString = $string;

        if ($this->config->allowPhpScripts === false) {
            $this->sourceString = preg_replace(
                '/<\\?.*(\\?>|$)/Us',
                '',
                str_replace('<?=', '<?php echo ', $this->sourceString)
            );
        }

        $this->sourceString = str_replace(
            [
                '__DIR__',
                '__FILE__',
            ],
            [
                "'" . $this->getSourceFileDirectory() . "'",
                "'" . $this->getSourceFilePath() . "'",
            ],
            $this->sourceString
        );

        return empty($this->sourceString);
    }
427931
public function parseFromString($string){
		$dom = $this->html5->loadHTML($string);
		if( is_a($dom, 'DOMDocument') ){
			return $dom;
		}else{
			return false;
		}
	}
900971
public static function parse( $url )
		{
			$uri = new phpUri( $url );

			/**
			 * CHANGE:
			 * @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>
			 * @since  24 Mai 2015 10:25 Uhr
			 * The base-url should always have a path
			 */
			if ( empty( $uri->path ) )
			{
				$uri->path = '/';
			}

			return $uri;
		}
416254
protected function doParse($string)
    {
        $userAgent = array(
            'string' => $this->cleanString($string),
            'browser_name' => null,
            'browser_version' => null,
            'browser_engine' => null,
            'operating_system' => null,
            'device' => 'Other'
        );

        if (empty($userAgent['string'])) {
            return $userAgent;
        }

        $browsers = $this->definition->getKnownBrowsers();
        $bots = $this->definition->getKnownBots();
        $userAgents = $browsers + $bots;

        // Find the right name/version phrase (or return empty array if none found)
        foreach ($userAgents as $name => $regexes) {
            if ($matches = $this->matchBrowser($regexes, $userAgent['string'])) {
                if (isset($matches[3])) {
                    $name = str_replace('*', strtolower($matches[2]), $name);
                }

                $userAgent['browser_name'] = $name;
                $userAgent['browser_version'] = end($matches);

                break;
            }
        }

        // Find browser engine
        $engines = $this->definition->getKnownEngines();
        if ($result = $this->find($engines, $userAgent['string'])) {
            $userAgent['browser_engine'] = $result;
        }

        // Find operating system
        $operatingSystems = $this->definition->getKnownOperatingSystems();
        if ($result = $this->find($operatingSystems, $userAgent['string'])) {
            $userAgent['operating_system'] = $result;
        }

        // Find device name
        $devices = $this->definition->getKnownDevices();
        if ($result = $this->find($devices, $userAgent['string'], true)) {
            $userAgent['device'] = $result;
        }

        return $userAgent;
    }
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;
    }
890923
public function deserialize($string)
    {
        $data = $this->serializer->deserialize($string);
        $messageSerializerData = MessageSerializerData::createFromArray($data);

        /** @var Message $className */
        $className = $messageSerializerData->className();

        return $className::deserialize($messageSerializerData->data());
    }
317306
public static function decode($string)
    {
        if (!$string) {
            return new ArrayObject();
        }

        $array = SymfonyYaml::parse($string);

        if (!is_array($array)) {
            $array = [];
        }

        return ArrayObject::make($array);
    }
95801
public function parse($string)
    {
        if (! $this->isSupports($string)) throw new \InvalidArgumentException('invalid string.');

        $define = new OptionDefine();
        preg_match($this->regexp_option, $string, $matches);

        // optional | required
        if ($matches[1] === 'require') $define->required();

        // long-name
        $define->setName($this->pickName($matches[2]));
        
        // short-name
        $define->setShortName($this->pickShortName($matches[2]));

        // defalt value
        $define->setDefault($this->pickValue($define, $matches[2]));
        
        // description
        $define->setDescription($this->pickDescription($matches));

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

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

        return $value;
    }
1199005
public function getParsedString($string)
    {
        $member = $this->getMember();
        $page = $this->getPage();

        /**
         * @var \SilverStripe\ORM\FieldType\DBDatetime $createdDateObj
         */
        $createdDateObj = $member->obj('Created');

        $absoluteBaseURL = $this->BaseURL();
        $variables = array(
            '$SiteName'       => SiteConfig::current_site_config()->Title,
            '$LoginLink'      => Controller::join_links(
                $absoluteBaseURL,
                singleton(Security::class)->Link('login')
            ),
            '$ConfirmLink'    => Controller::join_links(
                $this->page->AbsoluteLink('confirm'),
                $member->ID,
                "?key={$member->ValidationKey}"
            ),
            '$LostPasswordLink' => Controller::join_links(
                $absoluteBaseURL,
                singleton(Security::class)->Link('lostpassword')
            ),
            '$Member.Created' => $createdDateObj->Nice()
        );
        foreach (array('Name', 'FirstName', 'Surname', 'Email') as $field) {
            $variables["\$Member.$field"] = $member->$field;
        }
        $this->extend('updateEmailVariables', $variables);

        return str_replace(array_keys($variables), array_values($variables), $string);
    }
382350
public static function parse($string)
    {
        $matches = Regex::matchSemVer($string);

        // Parse the SemVer root
        $version = VersionableParser::parse(
            $matches[1],
            'Naneau\SemVer\Version'
        );

        // There is a pre-release part
        if (!empty($matches['prerelease'])) {
            $version->setPreRelease(
                PreReleaseParser::parse(
                    ltrim($matches['prerelease'], '-')
                )
            );
        }

        // There is a build number
        if (!empty($matches['build'])) {
            $version->setBuild(
                BuildParser::parse(
                    ltrim($matches['build'], '+')
                )
            );
        }

        // Return
        $version->setOriginalVersion($string);
        return $version;
    }
1091092
public function parse($uri)
    {
        parent::parse($uri);

        if (empty($this->path)) {
            $this->path = '/';
        }

        return $this;
    }
781597
public static function decode($string)
    {
        if (!$string) {
            return new ArrayObject();
        }

        $array = json_decode($string, true);

        static::checkLastError();

        if (!is_array($array)) {
            $array = [];
        }

        return ArrayObject::make($array);
    }