Completed
Pull Request — develop (#236)
by ANTHONIUS
09:12
created

Cv   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 67.86 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 2
dl 19
loc 28
rs 10
c 2
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A findDraft() 19 19 3

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
namespace Cv\Repository;
4
5
use Zend\ServiceManager\ServiceLocatorInterface;
6
use Core\Repository\AbstractRepository;
7
use Auth\Entity\UserInterface;
8
9
/**
10
 * class for accessing CVs
11
 */
12
class Cv extends AbstractRepository
13
{
14
    /**
15
     * Look for an drafted Document of a given user
16
     *
17
     * @param $user
18
     * @return \Cv\Entity\Cv|null
0 ignored issues
show
Documentation introduced by
Should the return type not be object|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
19
     */
20 View Code Duplication
    public function findDraft($user)
0 ignored issues
show
Duplication introduced by
This method 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...
21
    {
22
        if ($user instanceof UserInterface) {
23
            $user = $user->getId();
24
        }
25
26
        $document = $this->findOneBy(
27
            array(
28
                'isDraft' => true,
29
                'user' => $user
30
            )
31
        );
32
33
        if (!empty($document)) {
34
            return $document;
35
        }
36
37
        return null;
38
    }
39
}
40