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

SiteLinkLinker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Addwiki\Wikibase\Api\Service;
4
5
use Addwiki\Mediawiki\DataModel\EditInfo;
6
use Addwiki\Wikibase\Api\WikibaseApi;
7
use Wikibase\DataModel\SiteLink;
8
9
/**
10
 * @access private
11
 *
12
 * @author Addshore
13
 */
14
class SiteLinkLinker {
15
16
	private WikibaseApi $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 WikibaseApi $api
20
	 */
21
	public function __construct( WikibaseApi $api ) {
22
		$this->api = $api;
23
	}
24
25
	/**
26
	 * @since 0.2
27
	 * @param SiteLink $toSiteLink
28
	 * @param SiteLink $fromSiteLink
29
	 * @param EditInfo|null $editInfo
30
	 */
31
	public function link( SiteLink $toSiteLink, SiteLink $fromSiteLink, EditInfo $editInfo = null ): bool {
32
		$params = [
33
			'tosite' => $toSiteLink->getSiteId(),
34
			'totitle' => $toSiteLink->getPageName(),
35
			'fromsite' => $fromSiteLink->getSiteId(),
36
			'fromtitle' => $fromSiteLink->getPageName(),
37
		];
38
39
		$this->api->postRequest( 'wblinktitles', $params, $editInfo );
40
		return true;
41
	}
42
43
}
44