Completed
Push — master ( f21795...e63d25 )
by Janis
02:34
created

FileMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 3
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 3
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * nextCloud - ocr
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Janis Koehr <[email protected]>
9
 * @copyright Janis Koehr 2016
10
 */
11
12
namespace OCA\Ocr\Db;
13
14
use OCP\AppFramework\Db\Mapper;
15
use OCP\IDBConnection;
16
17
/**
18
 * Class FileMapper
19
 *
20
 * @package OCA\Ocr\Db
21
 */
22 View Code Duplication
class FileMapper extends Mapper {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
24
	/**
25
	 * FileMapper constructor.
26
	 * ATTENTION: the common methods like 'delete' 'update' and things like that will not work because we join and cleanup some columns!!!
27
	 *
28
	 * @param IDBConnection $db
29
	 */
30 6
	public function __construct(IDBConnection $db) {
31 6
		parent::__construct($db, 'filecache', 'OCA\Ocr\Db\File');
32 6
	}
33
34
	/**
35
	 * Find a specific file entity
36
	 *
37
	 * @param $fileid
38
	 * @return File
39
	 */
40 2
	public function find($fileid) {
41 2
		$sql = 'SELECT f.fileid AS fileid, f.path AS path, f.name as name, m.mimetype AS mimetype, s.id AS storagename FROM *PREFIX*filecache AS f, *PREFIX*mimetypes AS m, *PREFIX*storages AS s WHERE f.fileid = ? AND f.mimetype = m.id AND f.storage = s.numeric_id';
42 2
		return $this->findEntity($sql, [$fileid]);
43
	}
44
}