Query() public method

Returns the first result for a user defined query against the RDF
public Query ( string $query ) : PHPExiftool\Driver\Value\ValueInterface
$query string
return PHPExiftool\Driver\Value\ValueInterface The value
Beispiel #1
0
 /**
  * @covers PHPExiftool\RDFParser::Query
  * @covers PHPExiftool\RDFParser::readNodeValue
  */
 public function testQuery()
 {
     $xml = "<?xml version='1.0' encoding='UTF-8'?>\n            <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n            <rdf:Description xmlns:NeutronSpace='http://ns.exiftool.ca/NeutronSpace/1.0/'>\n                <NeutronSpace:SpecialRomain>Hello World !</NeutronSpace:SpecialRomain>\n                <NeutronSpace:SpecialRomainbase64 rdf:datatype='http://www.w3.org/2001/XMLSchema#base64Binary'>SGVsbG8gYmFzZTY0ICE=</NeutronSpace:SpecialRomainbase64>\n                <NeutronSpace:Multi>\n                    <rdf:Bag>\n                        <rdf:li>romain</rdf:li>\n                        <rdf:li>neutron</rdf:li>\n                    </rdf:Bag>\n                </NeutronSpace:Multi>\n            </rdf:Description>\n            </rdf:RDF>";
     $this->object->open($xml);
     $metadata_simple = $this->object->Query('NeutronSpace:SpecialRomain');
     $metadata_base64 = $this->object->Query('NeutronSpace:SpecialRomainbase64');
     $metadata_multi = $this->object->Query('NeutronSpace:Multi');
     $null_datas = $this->object->Query('NeutronSpace:NoData');
     $null_datas_2 = $this->object->Query('NamespaceUnknown:NoData');
     $this->assertNull($null_datas);
     $this->assertNull($null_datas_2);
     $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Mono', $metadata_simple);
     $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Binary', $metadata_base64);
     $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Multi', $metadata_multi);
     $this->assertEquals('Hello World !', $metadata_simple->asString());
     $this->assertEquals('Hello base64 !', $metadata_base64->asString());
     $this->assertEquals(array('romain', 'neutron'), $metadata_multi->asArray());
 }
Beispiel #2
0
 /**
  * Execute a user defined query to retrieve metadata
  *
  * @param string $query
  *
  * @return ValueInterface
  */
 public function executeQuery($query)
 {
     return $this->parser->Query($query);
 }