コード例 #1
0
 /**
  * @dataProvider supportedDataItemProvider
  */
 public function testMatchSupportedTypes($dataItem, $xsdValue, $xsdType)
 {
     $instance = new XsdValueMapper();
     $instance->process($dataItem);
     $this->assertEquals($xsdValue, $instance->getXsdValue());
     $this->assertContains($xsdType, $instance->getXsdType());
 }
コード例 #2
0
 private function initDataItemEncoderMap()
 {
     $lang = '';
     $xsdValueMapper = new XsdValueMapper();
     $this->registerDataItemEncoder(DataItem::TYPE_NUMBER, function ($dataItem) use($lang, $xsdValueMapper) {
         $xsdValueMapper->process($dataItem);
         return new ExpLiteral($xsdValueMapper->getXsdValue(), $xsdValueMapper->getXsdType(), $lang, $dataItem);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_BLOB, function ($dataItem) use($lang, $xsdValueMapper) {
         $xsdValueMapper->process($dataItem);
         return new ExpLiteral($xsdValueMapper->getXsdValue(), $xsdValueMapper->getXsdType(), $lang, $dataItem);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_BOOLEAN, function ($dataItem) use($lang, $xsdValueMapper) {
         $xsdValueMapper->process($dataItem);
         return new ExpLiteral($xsdValueMapper->getXsdValue(), $xsdValueMapper->getXsdType(), $lang, $dataItem);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_URI, function ($dataItem) {
         return new ExpResource($dataItem->getURI(), $dataItem);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_TIME, function ($dataItem) use($lang, $xsdValueMapper) {
         $gregorianTime = $dataItem->getForCalendarModel(DITime::CM_GREGORIAN);
         $xsdValueMapper->process($gregorianTime);
         return new ExpLiteral($xsdValueMapper->getXsdValue(), $xsdValueMapper->getXsdType(), $lang, $gregorianTime);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_CONTAINER, function ($dataItem) {
         return Exporter::getInstance()->makeExportData($dataItem->getSemanticData());
     });
     $this->registerDataItemEncoder(DataItem::TYPE_WIKIPAGE, function ($dataItem) {
         return Exporter::getInstance()->getResourceElementForWikiPage($dataItem);
     });
     $this->registerDataItemEncoder(DataItem::TYPE_PROPERTY, function ($dataItem) {
         return Exporter::getInstance()->getResourceElementForProperty($dataItem);
     });
     // Not implemented
     $this->registerDataItemEncoder(DataItem::TYPE_GEO, function ($dataItem) {
         return null;
     });
     // Not implemented
     $this->registerDataItemEncoder(DataItem::TYPE_CONCEPT, function ($dataItem) {
         return null;
     });
 }