Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
10 / 12 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
IndexDocument | |
83.33% |
10 / 12 |
|
66.67% |
4 / 6 |
7.23 | |
0.00% |
0 / 1 |
__construct | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBody | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getIndexProperties | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDynamicProperties | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAccessProperties | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2018 (original work) Open Assessment Technologies SA; |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\tao\model\search\index; |
24 | |
25 | use Iterator; |
26 | |
27 | /** |
28 | * Class IndexDocument |
29 | * @package oat\tao\model\search\index |
30 | */ |
31 | class IndexDocument |
32 | { |
33 | /** @var string */ |
34 | protected $id; |
35 | |
36 | /** @var array */ |
37 | protected $body; |
38 | |
39 | /** @var array */ |
40 | protected $indexesProperties; |
41 | |
42 | /** @var Iterator|null */ |
43 | private $dynamicProperties; |
44 | |
45 | /** @var Iterator|null */ |
46 | private $accessProperties; |
47 | |
48 | /** |
49 | * IndexDocument constructor. |
50 | * @param string $id |
51 | * @param array $body |
52 | * @param array $indexesProperties |
53 | * @param Iterator|null $dynamicProperties |
54 | * @param Iterator|null $accessProperties |
55 | * @throws \common_Exception |
56 | */ |
57 | public function __construct( |
58 | string $id, |
59 | array $body, |
60 | array $indexesProperties = [], |
61 | Iterator $dynamicProperties = null, |
62 | Iterator $accessProperties = null |
63 | ) { |
64 | $this->id = $id; |
65 | |
66 | if (!isset($body['type'])) { |
67 | throw new \common_Exception('Body of indexDocument should contain type key'); |
68 | } |
69 | $this->body = $body; |
70 | $this->indexesProperties = $indexesProperties; |
71 | $this->dynamicProperties = $dynamicProperties; |
72 | $this->accessProperties = $accessProperties; |
73 | } |
74 | |
75 | |
76 | public function getId(): string |
77 | { |
78 | return $this->id; |
79 | } |
80 | |
81 | /** |
82 | * Body of document |
83 | * |
84 | * $body['type'] = ['type1', 'type2']; |
85 | * $body['label'] = 'label'; |
86 | * $body[$field'] = $value; |
87 | * @return array |
88 | */ |
89 | public function getBody(): array |
90 | { |
91 | return $this->body; |
92 | } |
93 | |
94 | /** |
95 | * Array of IndexProperty |
96 | * |
97 | * @return array |
98 | */ |
99 | public function getIndexProperties(): array |
100 | { |
101 | return $this->indexesProperties; |
102 | } |
103 | |
104 | public function getDynamicProperties(): ?Iterator |
105 | { |
106 | return $this->dynamicProperties; |
107 | } |
108 | |
109 | public function getAccessProperties(): ?Iterator |
110 | { |
111 | return $this->accessProperties; |
112 | } |
113 | } |