FileMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 85.19 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A find() 3 6 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
/**
4
 * Nextcloud - OCR
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 2017
10
 */
11
namespace OCA\Ocr\Db;
12
13
use OCP\AppFramework\Db\Mapper;
14
use OCP\IDBConnection;
15
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
27
     * cleanup some columns!!!
28
     * 
29
     * @param IDBConnection $db            
30
     */
31 8
    public function __construct(IDBConnection $db) {
32 8
        parent::__construct($db, 'filecache', 'OCA\Ocr\Db\File');
33 8
    }
34
35
    /**
36
     * Find a specific file entity
37
     * 
38
     * @param
39
     *            $fileid
40
     * @return File
41
     */
42 2
    public function find($fileid) {
43 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';
44 2
        return $this->findEntity($sql, [
45 2
                $fileid
46
        ]);
47
    }
48
}