RevisionDeleter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 27
loc 27
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A delete() 16 16 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Mediawiki\Api\Service;
4
5
use Mediawiki\Api\SimpleRequest;
6
use Mediawiki\DataModel\Revision;
7
8
/**
9
 * @access private
10
 *
11
 * @author Addshore
12
 */
13 View Code Duplication
class RevisionDeleter extends Service {
0 ignored issues
show
Duplication introduced by
This class 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...
14
15
	/**
16
	 * @since 0.5
17
	 *
18
	 * @param Revision $revision
19
	 *
20
	 * @return bool
21
	 */
22
	public function delete( Revision $revision ) {
23
		$params = [
24
			'type' => 'revision',
25
			'hide' => 'content',
26
			// Note: pre 1.24 this is a delete token, post it is csrf
27
			'token' => $this->api->getToken( 'delete' ),
28
			'ids' => $revision->getId(),
29
		];
30
31
		$this->api->postRequest( new SimpleRequest(
32
			'revisiondelete',
33
			$params
34
		) );
35
36
		return true;
37
	}
38
39
}
40