SearchIndexAnnotation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 2
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Annotations;
14
15
use Maslosoft\Manganel\Manganel;
16
use Maslosoft\Manganel\Meta\ManganelTypeAnnotation;
17
18
/**
19
 * Search Index Annotation
20
 *
21
 * This annotation must be set to index document. Might be with empty value.
22
 * Use this to set Manganel configuration ID. This does **not** set index name,
23
 * use `Manganel`'s property `name` to set index name.
24
 *
25
 * Most simple example:
26
 * ```
27
 * @SearchIndex
28
 * ```
29
 *
30
 * @Target('class')
31
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
32
 */
33
class SearchIndexAnnotation extends ManganelTypeAnnotation
34
{
35
36
	const Ns = __NAMESPACE__;
37
38
	/**
39
	 * Index ID. This points to Manganel configuration instance.
40
	 * @var string
41
	 */
42
	public $value = null;
43
44 24
	public function init()
45
	{
46 24
		if (null === $this->value)
47
		{
48 23
			$this->value = Manganel::DefaultIndexId;
49
		}
50 24
		$this->getEntity()->indexId = $this->value;
51 24
	}
52
53
}
54