PageMover   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 55
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A move() 0 9 1
A moveFromPageId() 0 7 1
A getMoveParams() 0 8 1
1
<?php
2
3
namespace Mediawiki\Api\Service;
4
5
use Mediawiki\Api\SimpleRequest;
6
use Mediawiki\DataModel\Page;
7
use Mediawiki\DataModel\Title;
8
9
/**
10
 * @access private
11
 *
12
 * @author Addshore
13
 */
14
class PageMover extends Service {
15
16
	/**
17
	 * @since 0.2
18
	 *
19
	 * @param Page $page
20
	 * @param Title $target
21
	 * @param array $extraParams
22
	 *
23
	 * @return bool
24
	 */
25
	public function move( Page $page, Title $target, array $extraParams = [] ) {
26
		$this->api->postRequest(
27
			new SimpleRequest(
28
				'move', $this->getMoveParams( $page->getId(), $target, $extraParams )
0 ignored issues
show
Deprecated Code introduced by
The method Mediawiki\DataModel\Page::getId() has been deprecated with message: since 0.5

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
29
			)
30
		);
31
32
		return true;
33
	}
34
35
	/**
36
	 * @since 0.2
37
	 *
38
	 * @param int $pageid
39
	 * @param Title $target
40
	 * @param array $extraParams
41
	 *
42
	 * @return bool
43
	 */
44
	public function moveFromPageId( $pageid, Title $target, array $extraParams = [] ) {
45
		$this->api->postRequest(
46
			new SimpleRequest( 'move', $this->getMoveParams( $pageid, $target, $extraParams ) )
47
		);
48
49
		return true;
50
	}
51
52
	/**
53
	 * @param int $pageid
54
	 * @param Title $target
55
	 * @param array $extraParams
56
	 *
57
	 * @return array
58
	 */
59
	private function getMoveParams( $pageid, $target, $extraParams ) {
60
		$params = [];
61
		$params['fromid'] = $pageid;
62
		$params['to'] = $target->getTitle();
0 ignored issues
show
Deprecated Code introduced by
The method Mediawiki\DataModel\Title::getTitle() has been deprecated with message: in 0.6 use getText (makes things look cleaner)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
63
		$params['token'] = $this->api->getToken( 'move' );
64
65
		return array_merge( $extraParams, $params );
66
	}
67
68
}
69