Completed
Push — main ( b55b92...e8d442 )
by
unknown
05:41
created

BadgeIdsGetter   A

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
1
<?php
2
3
namespace Addwiki\Wikibase\Api\Service;
4
5
use Addwiki\Mediawiki\Api\Client\MediawikiApi;
6
use Addwiki\Mediawiki\Api\Client\SimpleRequest;
7
use Wikibase\DataModel\Entity\ItemId;
8
9
/**
10
 * @access private
11
 *
12
 * @author Addshore
13
 */
14
class BadgeIdsGetter {
15
16
	private MediawikiApi $api;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
17
18
	/**
19
	 * @param MediawikiApi $api
20
	 */
21
	public function __construct( MediawikiApi $api ) {
22
		$this->api = $api;
23
	}
24
25
	/**
26
	 * @since 0.5
27
	 * @return ItemId[]
28
	 */
29
	public function get(): array {
30
		$result = $this->api->getRequest( new SimpleRequest( 'wbavailablebadges' ) );
31
		$ids = [];
32
		foreach ( $result['badges'] as $badgeIdString ) {
33
			$ids[] = new ItemId( $badgeIdString );
34
		}
35
		return $ids;
36
	}
37
38
}
39