Completed
Push — main ( 2daa48...b5d932 )
by
unknown
08:38
created

PageMover::moveFromPageId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Addwiki\Mediawiki\Api\Service;
4
5
use Addwiki\Mediawiki\Api\Client\SimpleRequest;
6
use Addwiki\Mediawiki\DataModel\Page;
7
use Addwiki\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
	public function move( Page $page, Title $target, array $extraParams = [] ): bool {
24
		$this->api->postRequest(
25
			new SimpleRequest(
26
				'move', $this->getMoveParams( $page->getId(), $target, $extraParams )
27
			)
28
		);
29
30
		return true;
31
	}
32
33
	/**
34
	 * @since 0.2
35
	 *
36
	 *
37
	 */
38
	public function moveFromPageId( int $pageid, Title $target, array $extraParams = [] ): bool {
39
		$this->api->postRequest(
40
			new SimpleRequest( 'move', $this->getMoveParams( $pageid, $target, $extraParams ) )
41
		);
42
43
		return true;
44
	}
45
46
	/**
47
	 *
48
	 * @return mixed[]
49
	 */
50 View Code Duplication
	private function getMoveParams( int $pageid, \Addwiki\Mediawiki\DataModel\Title $target, array $extraParams ): array {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
		$params = [];
52
		$params['fromid'] = $pageid;
53
		$params['to'] = $target->getTitle();
54
		$params['token'] = $this->api->getToken( 'move' );
55
56
		return array_merge( $extraParams, $params );
57
	}
58
59
}
60