PageWatcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 8
dl 0
loc 25
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A watch() 0 16 4
1
<?php
2
3
namespace Mediawiki\Api\Service;
4
5
use Mediawiki\Api\SimpleRequest;
6
use Mediawiki\DataModel\Page;
7
8
/**
9
 * @access private
10
 *
11
 * @author Addshore
12
 */
13
class PageWatcher extends Service {
14
15
	/**
16
	 * @param Page $page
17
	 *
18
	 * @return bool
19
	 */
20
	public function watch( Page $page ) {
21
		$params = [
22
			'token' => $this->api->getToken( 'watch' ),
23
		];
24
		if ( $page->getPageIdentifier()->getId() !== null ) {
25
			$params['pageids'] = $page->getPageIdentifier()->getId();
26
		} elseif ( $page->getPageIdentifier()->getTitle() !== null ) {
27
			$params['titles'] = $page->getPageIdentifier()->getTitle()->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...
28
		} elseif ( $page->getRevisions()->getLatest() !== null ) {
29
			$params['revids'] = $page->getRevisions()->getLatest()->getId();
30
		}
31
32
		$this->api->postRequest( new SimpleRequest( 'watch', $params ) );
33
34
		return true;
35
	}
36
37
}
38