Ejemplo n.º 1
0
 /**
  * Read the node value, decode it if needed
  *
  * @param  \DOMNode       $node The node to read
  * @param  TagInterface   $tag  The tag associated
  * @return ValueInterface The value extracted
  */
 protected function readNodeValue(\DOMNode $node, TagInterface $tag = null)
 {
     $nodeName = $this->normalize($node->nodeName);
     if (is_null($tag) && TagFactory::hasFromRDFTagname($nodeName)) {
         $tag = TagFactory::getFromRDFTagname($nodeName);
     }
     if ($node->getElementsByTagNameNS(self::RDF_NAMESPACE, 'Bag')->length > 0) {
         $ret = array();
         foreach ($node->getElementsByTagNameNS(self::RDF_NAMESPACE, 'li') as $nodeElement) {
             $ret[] = $nodeElement->nodeValue;
         }
         if (is_null($tag) || $tag->isMulti()) {
             return new Multi($ret);
         } else {
             return new Mono(implode(' ', $ret));
         }
     } elseif ($node->getAttribute('rdf:datatype') === 'http://www.w3.org/2001/XMLSchema#base64Binary') {
         if (is_null($tag) || $tag->isBinary()) {
             return Binary::loadFromBase64(trim($node->nodeValue));
         } else {
             return new Mono(base64_decode(trim($node->nodeValue)));
         }
     } else {
         if (!is_null($tag) && $tag->isMulti()) {
             return new Multi($node->nodeValue);
         } else {
             return new Mono($node->nodeValue);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @covers PHPExiftool\Driver\Value\Binary::loadFromBase64
  * @covers \PHPExiftool\Exception\InvalidArgumentException
  * @expectedException \PHPExiftool\Exception\InvalidArgumentException
  */
 public function testLoadFromWrongBase64()
 {
     $object = Binary::loadFromBase64('Uncle Scrooge !!!');
 }