BadgeIdsGetter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

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