/**
  * @see ValueFormatter::format
  *
  * Format an EntityIdValue
  *
  * @since 0.5
  *
  * @param EntityIdValue $value
  *
  * @throws InvalidArgumentException
  * @return string Either plain text, wikitext or HTML, depending on the EntityIdFormatter
  *  provided.
  */
 public function format($value)
 {
     if (!$value instanceof EntityIdValue) {
         throw new InvalidArgumentException('Data value type mismatch. Expected an EntityIdValue.');
     }
     return $this->entityIdFormatter->formatEntityId($value->getEntityId());
 }
 private function buildEntityIdValueForSearch(PropertyId $propertyId, EntityIdValue $entityIdValue)
 {
     $entityId = $entityIdValue->getEntityId();
     if (!($entityId instanceof ItemId || $entityId instanceof PropertyId)) {
         throw new FeatureNotSupportedException('Not supported entity type: ' . $entityId->getEntityType());
     }
     return $propertyId->getSerialization() . '-' . $entityIdValue->getEntityId()->getSerialization();
 }
 private function buildEntityIdValueForSearch(EntityIdValue $entityIdValue, PropertyId $propertyId)
 {
     $entityId = $entityIdValue->getEntityId();
     if (!$entityId instanceof ItemId) {
         throw new FeatureNotSupportedException('Not supported entity type: ' . $entityId->getEntityType());
     }
     return new ClaimQuery($propertyId, $entityId);
 }
예제 #4
0
 public function testCanConstruct()
 {
     $entityId = new ItemId('Q123');
     $entityIdValue = new EntityIdValue($entityId);
     $this->assertEquals($entityId, $entityIdValue->getEntityId());
 }