ShareMapper::__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 ShareMapper
19
 * 
20
 * @package OCA\Ocr\Db
21
 */
22 View Code Duplication
class ShareMapper 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
     * ShareMapper constructor.
26
     * 
27
     * @param IDBConnection $db            
28
     */
29 8
    public function __construct(IDBConnection $db) {
30 8
        parent::__construct($db, 'share', 'OCA\Ocr\Db\Share');
31 8
    }
32
33
    /**
34
     * Find the right name for a shared file
35
     * 
36
     * @param integer $fileid            
37
     * @param string $shareWith            
38
     * @param string $owner            
39
     * @return Share
40
     */
41 2
    public function find($fileid, $shareWith, $owner) {
42 2
        $sql = 'SELECT file_target FROM *PREFIX*share WHERE file_source = ? AND share_with = ? AND uid_owner = ?';
43 2
        return $this->findEntity($sql, [
44 2
                $fileid,
45 2
                $shareWith,
46 2
                $owner
47
        ]);
48
    }
49
}