WordPoints_Importer_Mock   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 4
lcom 2
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A is_available() 0 3 1
A do_an_import() 0 4 1
A can_import() 0 6 1
A cant_import() 0 6 1
1
<?php
2
3
/**
4
 * Mocks for abstract classes used in the unit tests.
5
 *
6
 * @package WordPoints_Importer\Tests
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * A mock for the WordPoints_Importer class.
12
 *
13
 * @since 1.0.0
14
 */
15
class WordPoints_Importer_Mock extends WordPoints_Importer {
16
17
	/**
18
	 * @since 1.0.0
19
	 */
20
	public $components;
21
22
	/**
23
	 * The "imports" performed.
24
	 *
25
	 * @since 1.0.0
26
	 *
27
	 * @var array
28
	 */
29
	public $imports = array();
30
31
	/**
32
	 * The "imports" for that were checked for possible performance.
33
	 *
34
	 * @since 1.0.0
35
	 *
36
	 * @var array
37
	 */
38
	public $can_imports;
39
40
	/**
41
	 * Whether this importer is available.
42
	 *
43
	 * @since 1.0.0
44
	 *
45
	 * @var true|WP_Error
46
	 */
47
	public $is_available = true;
48
49
	/**
50
	 * @since 1.0.0
51
	 */
52
	public function is_available() {
53
		return $this->is_available;
54
	}
55
56
	/**
57
	 * Mock an import method.
58
	 *
59
	 * @since 1.0.0
60
	 *
61
	 * @param array $settings The settings for this "component".
62
	 */
63
	public function do_an_import( $settings ) {
64
65
		$this->imports[] = $settings;
66
	}
67
68
	/**
69
	 * Mock a can_import method.
70
	 *
71
	 * @since 1.0.0
72
	 *
73
	 * @param array $settings The settings for this "component".
74
	 *
75
	 * @return true
76
	 */
77
	public function can_import( $settings ) {
78
79
		$this->can_imports[] = $settings;
80
81
		return true;
82
	}
83
84
	/**
85
	 * Return a WP_Error because we can't do the import for an option.
86
	 *
87
	 * @since 1.0.0
88
	 *
89
	 * @param array $settings The settings for this "component".
90
	 *
91
	 * @return WP_Error An error.
92
	 */
93
	public function cant_import( $settings ) {
94
95
		$this->can_imports[] = $settings;
96
97
		return new WP_Error();
98
	}
99
}
100
101
// EOF
102