hasFromRDFTagname() public static method

public static hasFromRDFTagname ( $tagname )
Esempio 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);
         }
     }
 }
 /**
  * @covers \PHPExiftool\Driver\TagFactory::HasFromRDFTagname
  */
 public function testHasFromRDFTagname()
 {
     $this->assertTrue(TagFactory::hasFromRDFTagname('IPTC:SupplementalCategories'));
     $this->assertFalse(TagFactory::hasFromRDFTagname('XMPExif:AnunexistingTag'));
 }