public static function parse($uri)
{
if (!is_string($uri)) {
throw new InvalidUriException(sprintf('The URI must be a string, but is a %s.', is_object($uri) ? get_class($uri) : gettype($uri)));
}
if (false !== ($pos = strpos($uri, '://'))) {
$parts = array(substr($uri, 0, $pos), substr($uri, $pos + 3));
if (!ctype_alnum($parts[0])) {
throw new InvalidUriException(sprintf('The URI "%s" is invalid. The scheme should consist of ' . 'alphabetic characters only.', $uri));
}
if (!ctype_alpha($parts[0][0])) {
throw new InvalidUriException(sprintf('The URI "%s" is invalid. The scheme should start with a letter.', $uri));
}
} else {
$parts = array('', $uri);
}
if ('' === $parts[1]) {
throw new InvalidUriException(sprintf('The URI "%s" is invalid. The path should not be empty.', $uri));
}
if ('/' !== $parts[1][0]) {
throw new InvalidUriException(sprintf('The URI "%s" is invalid. The path should start with a ' . 'forward slash ("/").', $uri));
}
return array('scheme' => $parts[0], 'path' => $parts[1]);
}