Пример #1
0
 /**
  * Resolve a relative $url to a canonical path based
  * on the LocalFileResolver's base path.
  *
  * @param string $url A URL to be resolved.
  * @throws \qtism\common\ResolutionException If $url cannot be resolved.
  */
 public function resolve($url)
 {
     $baseUrl = Utils::sanitizeUri($this->getBasePath());
     $baseDir = pathinfo($baseUrl, PATHINFO_DIRNAME);
     if (empty($baseDir)) {
         $msg = "The base directory of the document ('{$baseDir}') could not be resolved.";
         throw new ResolutionException($msg);
     }
     $href = $baseDir . '/' . ltrim($url, '/');
     return $href;
 }
Пример #2
0
 /**
  * @dataProvider invalidUriToSanitizeProvider
  */
 public function testInvalidUriToSanitize($uri)
 {
     $this->setExpectedException('\\InvalidArgumentException');
     $uri = Utils::sanitizeUri($uri);
 }