SiteLinkLinker   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0
ccs 0
cts 11
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A link() 0 11 1
1
<?php
2
3
namespace Wikibase\Api\Service;
4
5
use Mediawiki\DataModel\EditInfo;
6
use Wikibase\Api\WikibaseApi;
7
use Wikibase\DataModel\SiteLink;
8
9
/**
10
 * @access private
11
 *
12
 * @author Addshore
13
 */
14
class SiteLinkLinker {
15
16
	/**
17
	 * @var WikibaseApi
18
	 */
19
	private $api;
20
21
	/**
22
	 * @param WikibaseApi $api
23
	 */
24
	public function __construct( WikibaseApi $api ) {
25
		$this->api = $api;
26
	}
27
28
	/**
29
	 * @since 0.2
30
	 * @param SiteLink $toSiteLink
31
	 * @param SiteLink $fromSiteLink
32
	 * @param EditInfo|null $editInfo
33
	 *
34
	 * @returns bool
35
	 */
36
	public function link ( SiteLink $toSiteLink, SiteLink $fromSiteLink, EditInfo $editInfo = null ) {
37
		$params = array(
38
			'tosite' => $toSiteLink->getSiteId(),
39
			'totitle' => $toSiteLink->getPageName(),
40
			'fromsite' => $fromSiteLink->getSiteId(),
41
			'fromtitle' => $fromSiteLink->getPageName(),
42
		);
43
44
		$this->api->postRequest( 'wblinktitles', $params, $editInfo );
45
		return true;
46
	}
47
48
}