public function testSerialize()
 {
     $input = new ItemType();
     $input->setLabel('City');
     $input->setItemId(new ItemId('Q42'));
     $input->setApiUrl('http://api.queryr.com/items/Q42');
     $input->setWikidataUrl('http://www.wikidata.org/entity/Q42');
     $expected = ['label' => 'City', 'id' => 'Q42', 'url' => 'http://api.queryr.com/items/Q42', 'wikidata_url' => 'http://www.wikidata.org/entity/Q42'];
     $output = (new ItemTypeSerializer())->serialize($input);
     $this->assertSame($expected, $output);
 }
 /**
  * @param ItemTypesListingRequest $request
  *
  * @return ItemType[]
  */
 public function listItemTypes(ItemTypesListingRequest $request) : array
 {
     return array_map(function (ItemId $id) use($request) : ItemType {
         $itemType = new ItemType();
         $itemType->setItemId($id);
         $itemType->setApiUrl($this->urlBuilder->getApiItemUrl($id));
         $itemType->setWikidataUrl($this->urlBuilder->getWdEntityUrl($id));
         $label = $this->labelLookup->getLabelByIdAndLanguage($id, $request->getLanguageCode());
         $itemType->setLabel($label === null ? $id->getSerialization() : $label);
         return $itemType;
     }, array_map('\\Wikibase\\DataModel\\Entity\\ItemId::newFromNumber', $this->itemStore->getItemTypes($request->getPerPage(), ($request->getPage() - 1) * $request->getPerPage())));
 }
 private function serializeItemType(ItemType $itemType)
 {
     return ['label' => $itemType->getLabel(), 'id' => $itemType->getItemId()->getSerialization(), 'url' => $itemType->getApiUrl(), 'wikidata_url' => $itemType->getWikidataUrl()];
 }