Completed
Push — master ( 2ecbfa...83ed09 )
by Maxence
12:07
created

FilesDocument::fromIndexDocument()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
5
/**
6
 * Files_FullTextSearch - Index the content of your files
7
 *
8
 * This file is licensed under the Affero General Public License version 3 or
9
 * later. See the COPYING file.
10
 *
11
 * @author Maxence Lange <[email protected]>
12
 * @copyright 2018
13
 * @license GNU AGPL version 3 or any later version
14
 *
15
 * This program is free software: you can redistribute it and/or modify
16
 * it under the terms of the GNU Affero General Public License as
17
 * published by the Free Software Foundation, either version 3 of the
18
 * License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU Affero General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU Affero General Public License
26
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
 *
28
 */
29
30
31
namespace OCA\Files_FullTextSearch\Model;
32
33
34
use OCP\Files_FullTextSearch\Model\AFilesDocument;
35
use OCP\FullTextSearch\Model\IndexDocument;
36
37
38
/**
39
 * Class FilesDocument
40
 *
41
 * @package OCA\Files_FullTextSearch\Model
42
 */
43
class FilesDocument extends AFilesDocument {
44
45
46
	const STATUS_FILE_ACCESS = 1024;
47
48
49
	/** @var string */
50
	private $ownerId = '';
51
52
	/** @var string */
53
	private $viewerId = '';
54
55
	/** @var string */
56
	private $type = '';
57
58
	/** @var string */
59
	private $mimetype = '';
60
61
	/** @var string */
62
	private $path = '';
63
64
65
	/**
66
	 * @param string $ownerId
67
	 *
68
	 * @return $this
69
	 */
70
	public function setOwnerId(string $ownerId): FilesDocument {
71
		$this->ownerId = $ownerId;
72
73
		return $this;
74
	}
75
76
	/**
77
	 * @return string
78
	 */
79
	public function getOwnerId(): string {
80
		return $this->ownerId;
81
	}
82
83
84
	/**
85
	 * @param string $viewerId
86
	 *
87
	 * @return FilesDocument
88
	 */
89
	public function setViewerId(string $viewerId): FilesDocument {
90
		$this->viewerId = $viewerId;
91
92
		return $this;
93
	}
94
95
	/**
96
	 * @return string
97
	 */
98
	public function getViewerId(): string {
99
		return $this->viewerId;
100
	}
101
102
103
	/**
104
	 * @param string $type
105
	 *
106
	 * @return FilesDocument
107
	 */
108
	public function setType(string $type): FilesDocument {
109
		$this->type = $type;
110
111
		return $this;
112
	}
113
114
	/**
115
	 * @return string
116
	 */
117
	public function getType(): string {
118
		return $this->type;
119
	}
120
121
122
	/**
123
	 * @param string $type
124
	 *
125
	 * @return FilesDocument
126
	 */
127
	public function setMimetype(string $type): FilesDocument {
128
		$this->mimetype = $type;
129
130
		return $this;
131
	}
132
133
	/**
134
	 * @return string
135
	 */
136
	public function getMimetype(): string {
137
		return $this->mimetype;
138
	}
139
140
141
	/**
142
	 * @param string $path
143
	 *
144
	 * @return $this
145
	 */
146
	public function setPath(string $path): FilesDocument {
147
		$this->path = $path;
148
149
		return $this;
150
	}
151
152
	/**
153
	 * @return string
154
	 */
155
	public function getPath(): string {
156
		return $this->path;
157
	}
158
159
160
	/**
161
	 * @param IndexDocument $indexDocument
162
	 *
163
	 * @return FilesDocument
164
	 */
165
	public static function fromIndexDocument(IndexDocument $indexDocument) {
166
		$document = new FilesDocument($indexDocument->getProviderId(), $indexDocument->getId());
167
168
		foreach (get_object_vars($indexDocument) as $key => $name) {
169
			$document->$key = $name;
170
		}
171
172
		return $document;
173
	}
174
175
176
	/**
177
	 *
178
	 */
179
	public function __destruct() {
180
		parent::__destruct();
181
182
		unset($this->ownerId);
183
		unset($this->viewerId);
184
		unset($this->type);
185
		unset($this->mimetype);
186
		unset($this->path);
187
	}
188
189
}
190
191