BadgeIdsGetter::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Wikibase\Api\Service;
4
5
use Mediawiki\Api\MediawikiApi;
6
use Mediawiki\Api\SimpleRequest;
7
use Wikibase\DataModel\Entity\ItemId;
8
9
/**
10
 * @access private
11
 *
12
 * @author Addshore
13
 */
14
class BadgeIdsGetter {
15
16
	/**
17
	 * @var MediawikiApi
18
	 */
19
	private $api;
20
21
	/**
22
	 * @param MediawikiApi $api
23
	 */
24
	public function __construct( MediawikiApi $api ) {
25
		$this->api = $api;
26
	}
27
28
	/**
29
	 * @since 0.5
30
	 * @return ItemId[]
31
	 */
32
	public function get() {
33
		$result = $this->api->getRequest( new SimpleRequest( 'wbavailablebadges' ) );
34
		$ids = [];
35
		foreach ( $result['badges'] as $badgeIdString ) {
36
			$ids[] = new ItemId( $badgeIdString );
37
		}
38
		return $ids;
39
	}
40
41
}
42