Completed
Push — master ( 388143...889690 )
by Thomas
05:32 queued 02:57
created

EntityStore::getEntityLookup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Wikibase\EntityStore;
4
5
use Wikibase\DataModel\Services\Lookup\EntityLookup;
6
use Wikibase\DataModel\Services\Lookup\ItemLookup;
7
use Wikibase\DataModel\Services\Lookup\PropertyLookup;
8
9
/**
10
 * @licence GPLv2+
11
 * @author Thomas Pellissier Tanon
12
 */
13
abstract class EntityStore {
14
15
	/**
16
	 * Only stores/and returns labels, descriptions and aliases in these languages
17
	 */
18
	const OPTION_LANGUAGES = 'languages';
19
20
	/**
21
	 * Enables the language fallback system
22
	 */
23
	const OPTION_LANGUAGE_FALLBACK = 'languagefallback';
24
25
	/**
26
	 * @var EntityStoreOptions
27
	 */
28
	private $options;
29
30
	/**
31
	 * @param EntityStoreOptions $options
32
	 */
33 11
	public function __construct( EntityStoreOptions $options = null ) {
34 11
		$this->options = $options ?: new EntityStoreOptions();
35
36 11
		$this->setupOptions();
37 11
	}
38
39 11
	private function setupOptions() {
40 11
		$this->defaultOption( self::OPTION_LANGUAGES, null );
41 11
		$this->defaultOption( self::OPTION_LANGUAGE_FALLBACK, false );
42 11
	}
43
44
	/**
45
	 * @return EntityLookup
46
	 */
47 1
	public function getEntityLookup() {
48 1
		throw new FeatureNotSupportedException( 'EntityLookup not supported.' );
49
	}
50
51
	/**
52
	 * @return EntityDocumentLookup
53
	 */
54 1
	public function getEntityDocumentLookup() {
55 1
		throw new FeatureNotSupportedException( 'EntityDocumentLookup not supported.' );
56
	}
57
58
	/**
59
	 * @return ItemLookup
60
	 */
61 1
	public function getItemLookup() {
62 1
		throw new FeatureNotSupportedException( 'ItemLookup not supported.' );
63
	}
64
65
	/**
66
	 * @return PropertyLookup
67
	 */
68 1
	public function getPropertyLookup() {
69 1
		throw new FeatureNotSupportedException( 'PropertyLookup not supported.' );
70
	}
71
72
	/**
73
	 * @return ItemIdForTermLookup
74
	 */
75 1
	public function getItemIdForTermLookup() {
76 1
		throw new FeatureNotSupportedException( 'ItemIdForTermLookup not supported.' );
77
	}
78
79
	/**
80
	 * @return PropertyIdForTermLookup
81
	 */
82 1
	public function getPropertyIdForTermLookup() {
83 1
		throw new FeatureNotSupportedException( 'PropertyIdForTermLookup not supported.' );
84
	}
85
86
	/**
87
	 * @return ItemIdForQueryLookup
88
	 */
89 1
	public function getItemIdForQueryLookup() {
90 1
		throw new FeatureNotSupportedException( 'ItemIdForQueryLookup not supported.' );
91
	}
92
93
	/**
94
	 * @return PropertyIdForQueryLookup
95
	 */
96 1
	public function getPropertyIdForQueryLookup() {
97 1
		throw new FeatureNotSupportedException( 'PropertyIdForQueryLookup not supported.' );
98
	}
99
100
	/**
101
	 * @return EntityDocumentSaver
102
	 */
103 1
	public function getEntityDocumentSaver() {
104 1
		throw new FeatureNotSupportedException( 'EntityDocumentSaver not supported.' );
105
	}
106
107
	/**
108
	 * Setup the EntityStore if it has not been done yet (create database tables...).
109
	 *
110
	 * It should not drop data if the store is already setup.
111
	 */
112
	public function setupStore() {
113
	}
114
115
	/**
116
	 * Setup the indexes if it has not been done yet.
117
	 *
118
	 * Often called after big importations to create again indexes.
119
	 */
120
	public function setupIndexes() {
121
	}
122
123
	/**
124
	 * @return EntityStoreOptions
125
	 */
126 2
	protected function getOptions() {
127 2
		return $this->options;
128
	}
129
130
	/**
131
	 * @see EntityStoreOptions::getOption
132
	 */
133 1
	protected function getOption( $option ) {
134 1
		return $this->options->getOption( $option );
135
	}
136
137
	/**
138
	 * @see EntityStoreOptions::defaultOption
139
	 */
140 11
	protected function defaultOption( $option, $default ) {
141 11
		$this->options->defaultOption( $option, $default );
142 11
	}
143
}
144