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

FileMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A find() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}