Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Ejemplo n.º 1
0
 /**
  * @dataProvider provideInvalidUris
  * @expectedException \Puli\Repository\Uri\InvalidUriException
  */
 public function testParseInvalid($uri)
 {
     Uri::parse($uri);
 }
 /**
  * {@inheritdoc}
  *
  * @internal
  */
 public function url_stat($uri, $flags)
 {
     try {
         $parts = Uri::parse($uri);
         $resource = $this->getRepository($parts['scheme'])->get($parts['path']);
         if ($resource instanceof FilesystemResource) {
             $path = $resource->getFilesystemPath();
             if ($flags & STREAM_URL_STAT_LINK) {
                 return lstat($path);
             }
             return stat($path);
         }
         $stat = self::$defaultStat;
         if ($resource instanceof BodyResource) {
             $stat[self::SIZE_NUM] = $stat[self::SIZE_ASSOC] = $resource->getSize();
         }
         $metadata = $resource->getMetadata();
         $stat[self::ACCESS_TIME_NUM] = $stat[self::ACCESS_TIME_ASSOC] = $metadata->getAccessTime();
         $stat[self::MODIFY_TIME_NUM] = $stat[self::MODIFY_TIME_ASSOC] = $metadata->getModificationTime();
         return $stat;
     } catch (ResourceNotFoundException $e) {
         if ($flags & STREAM_URL_STAT_QUIET) {
             // Same result as stat() returns on error
             // file_exists() returns false for this resource
             return false;
         }
         throw $e;
     }
 }