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

PagePurger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 61.53%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 45
ccs 8
cts 13
cp 0.6153
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A purgeGenerator() 0 7 1
A __construct() 0 3 1
A purge() 0 7 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