reset() public method

public reset ( )
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function read($filename)
 {
     $meta = new ValueBag();
     try {
         $fileEntity = $this->reader->reset()->files($filename)->first();
     } catch (\Exception $e) {
         return $meta;
     }
     if ($fileEntity->getMetadatas()->containsKey('File:ImageWidth')) {
         $meta->set('image.width', new MetaValue((int) $fileEntity->getMetadatas()->get('File:ImageWidth')->getValue()->asString()));
     } elseif ($fileEntity->getMetadatas()->containsKey('PNG:ImageWidth')) {
         $meta->set('image.width', new MetaValue((int) $fileEntity->getMetadatas()->get('PNG:ImageWidth')->getValue()->asString()));
     }
     if ($fileEntity->getMetadatas()->containsKey('File:ImageHeight')) {
         $meta->set('image.height', new MetaValue((int) $fileEntity->getMetadatas()->get('File:ImageHeight')->getValue()->asString()));
     } elseif ($fileEntity->getMetadatas()->containsKey('PNG:ImageHeight')) {
         $meta->set('image.height', new MetaValue((int) $fileEntity->getMetadatas()->get('PNG:ImageHeight')->getValue()->asString()));
     }
     foreach ($fileEntity->getMetadatas() as $metadata) {
         /* @var $metadata Metadata */
         if (ValueInterface::TYPE_BINARY === $metadata->getValue()->getType()) {
             continue;
         }
         $groupName = $metadata->getTag()->getGroupName();
         $name = $metadata->getTag()->getName();
         $value = (string) $metadata->getValue();
         if ($groupName === 'System' || !ctype_print($value)) {
             continue;
         }
         $path = "{$groupName}.{$name}";
         $meta->set($path, new MetaValue($value));
     }
     return $meta;
 }