ShareMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 82.14 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 23
loc 28
ccs 9
cts 9
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 8 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 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
}