public function getResult(Request $request)
 {
     $listingRequest = new ItemTypesListingRequest();
     // TODO: strict validation of arguments
     $listingRequest->setPerPage((int) $request->get('per_page', 100));
     $listingRequest->setPage((int) $request->get('page', 1));
     $itemTypes = $this->apiFactory->newListItemTypesUseCase()->listItemTypes($listingRequest);
     $response = $this->app->json($this->getSerializedTypes($itemTypes));
     (new PaginationHeaderSetter($response->headers))->setHeaders($request->getUriForPath('/items/types'), $listingRequest, count($itemTypes));
     return $response;
 }
 /**
  * @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())));
 }