Completed
Push — master ( 59d864...868015 )
by adam
12s
created

PagePurger::purge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Mediawiki\Api\Service;
4
5
use Mediawiki\Api\Generator\ApiGenerator;
6
use Mediawiki\Api\MediawikiApi;
7
use Mediawiki\Api\SimpleRequest;
8
use Mediawiki\DataModel\Page;
9
10
/**
11
 * @access private
12
 *
13
 * @author Addshore
14
 * @author Thomas Arrow
15
 */
16
class PagePurger {
17
18
	/**
19
	 * @var MediawikiApi
20
	 */
21
	private $api;
22
23
	/**
24
	 * @param MediawikiApi $api
25
	 */
26 2
	public function __construct( MediawikiApi $api ) {
27 2
		$this->api = $api;
28 2
	}
29
30
	/**
31
	 * @since 0.3
32
	 *
33
	 * @param Page $page
34
	 *
35
	 * @return bool
36
	 */
37 1
	public function purge( Page $page ) {
38 1
		$this->api->postRequest(
39 1
			new SimpleRequest( 'purge', [ 'pageids' => $page->getId() ] )
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...
40 1
		);
41
42 1
		return true;
43
	}
44
45
	/**
46
	 * @since 0.6
47
	 *
48
	 * @param ApiGenerator $generator
49
	 *
50
	 * @return bool
51
	 */
52
	public function purgeGenerator( ApiGenerator $generator ) {
53
		$this->api->postRequest(
54
			new SimpleRequest( 'purge', $generator->getParams() )
55
		);
56
57
		return true;
58
	}
59
60
}
61