FileMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 3
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 3
loc 3
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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
}