Completed
Push — master ( 6867ea...535d08 )
by Jeroen De
62:35 queued 52:37
created

PageCreator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createPage() 0 8 1
A createPageWithContent() 0 8 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Util;
6
7
use CommentStoreComment;
8
use Title;
9
use User;
10
11
/**
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class PageCreator {
16
17
	public function createPage( string $title, string $content = null ) {
18
		$titleObject = Title::newFromText( $title );
19
20
		$this->createPageWithContent(
21
			$title,
22
			\ContentHandler::makeContent( $content ?? 'Content of ' . $title, $titleObject )
23
		);
24
	}
25
26
	public function createPageWithContent( string $title, \Content $content ) {
27
		$titleObject = Title::newFromText( $title );
28
		$page = new \WikiPage( $titleObject );
29
30
		$updater = $page->newPageUpdater( User::newSystemUser( 'TestUser' ) );
31
		$updater->setContent( 'main', $content );
32
		$updater->saveRevision( CommentStoreComment::newUnsavedComment( __CLASS__ . ' creating page ' . $title ) );
33
	}
34
35
}
36