PageMover::move()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
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