ServicesFactory   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 82
ccs 19
cts 19
cp 1
rs 10
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setConnection() 0 2 1
A newDatabaseLogReader() 0 2 1
A getConnection() 0 7 2
A newApprovedDatePropertyAnnotator() 0 2 1
A newApprovedRevsFacade() 0 2 1
A newApprovedByPropertyAnnotator() 0 2 1
A newApprovedStatusPropertyAnnotator() 0 2 1
A newApprovedRevPropertyAnnotator() 0 2 1
1
<?php
2
3
namespace SMW\ApprovedRevs;
4
5
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedByPropertyAnnotator;
6
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedStatusPropertyAnnotator;
7
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedDatePropertyAnnotator;
8
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedRevPropertyAnnotator;
9
use Title;
0 ignored issues
show
Bug introduced by
The type Title was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class ServicesFactory {
18
19
	/**
20
	 * @var DatabaseBase
0 ignored issues
show
Bug introduced by
The type SMW\ApprovedRevs\DatabaseBase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
	 */
22
	private $connection;
23
24
	/**
25
	 * @since 1.0
26
	 */
27 2
	public function setConnection( \DatabaseBase $connection ) {
0 ignored issues
show
Bug introduced by
The type DatabaseBase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28 2
		$this->connection = $connection;
29 2
	}
30
31
	/**
32
	 * @since 1.3
33
	 *
34
	 * @return DatabaseBase
35
	 */
36 5
	public function getConnection() {
37
38 5
		if ( $this->connection === null ) {
39 3
			$this->connection = wfGetDB( DB_REPLICA );
0 ignored issues
show
Bug introduced by
The constant SMW\ApprovedRevs\DB_REPLICA was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The function wfGetDB was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
			$this->connection = /** @scrutinizer ignore-call */ wfGetDB( DB_REPLICA );
Loading history...
40
		}
41
42 5
		return $this->connection;
43
	}
44
45
	/**
46
	 * @since 1.0
47
	 *
48
	 * @return ApprovedRevsFacade
49
	 */
50 2
	public function newApprovedRevsFacade() {
51 2
		return new ApprovedRevsFacade();
52
	}
53
54
	/**
55
	 * @since 1.0
56
	 *
57
	 * @param null|Title $title to get the DBLogReader
58
	 * @param string $type which log entries to get (default: approval)
59
	 * @return DatabaseLogReader
60
	 */
61 4
	public function newDatabaseLogReader( Title $title = null, $type = 'approval' ) {
62 4
		return new DatabaseLogReader( $this->getConnection(), $title, $type );
63
	}
64
65
	/**
66
	 * @since 1.0
67
	 *
68
	 * @return ApprovedByPropertyAnnotator
69
	 */
70 1
	public function newApprovedByPropertyAnnotator() {
71 1
		return new ApprovedByPropertyAnnotator( $this->newDatabaseLogReader() );
72
	}
73
74
	/**
75
	 * @since 1.0
76
	 *
77
	 * @return ApprovedStatusPropertyAnnotator
78
	 */
79 1
	public function newApprovedStatusPropertyAnnotator() {
80 1
		return new ApprovedStatusPropertyAnnotator( $this->newDatabaseLogReader() );
81
	}
82
83
	/**
84
	 * @since 1.0
85
	 *
86
	 * @return ApprovedDatePropertyAnnotator
87
	 */
88 1
	public function newApprovedDatePropertyAnnotator() {
89 1
		return new ApprovedDatePropertyAnnotator( $this->newDatabaseLogReader() );
90
	}
91
92
	/**
93
	 * @since 1.0
94
	 *
95
	 * @return ApprovedRevPropertyAnnotator
96
	 */
97 1
	public function newApprovedRevPropertyAnnotator() {
98 1
		return new ApprovedRevPropertyAnnotator( $this->newApprovedRevsFacade() );
99
	}
100
101
}
102