Completed
Push — develop ( e1a849...b559a4 )
by
unknown
07:42
created

Cv   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 49.06 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 26
loc 53
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPaginatorCursor() 0 6 1
A getPaginationQueryBuilder() 7 7 1
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
     * Gets a pointer to access a CV
16
     *
17
     * @param array $params
18
     */
19
    public function getPaginatorCursor($params)
20
    {
21
        return $this->getPaginationQueryBuilder($params)
22
                    ->getQuery()
23
                    ->execute();
24
    }
25
    /**
26
     * Gets a query builder to search for CVs
27
     *
28
     * @param array $params
29
     * @return unknown
30
     */
31 View Code Duplication
    protected function getPaginationQueryBuilder($params)
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...
32
    {
33
        $filter = $this->getService('filterManager')->get('Applications/PaginationQuery');
34
        $qb = $filter->filter($params, $this->createQueryBuilder());
35
    
36
        return $qb;
37
    }
38
39
    /**
40
     * Look for an drafted Document of a given user
41
     *
42
     * @param $user
43
     * @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...
44
     */
45 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...
46
    {
47
        if ($user instanceof UserInterface) {
48
            $user = $user->getId();
49
        }
50
51
        $document = $this->findOneBy(
52
            array(
53
                'isDraft' => true,
54
                'user' => $user
55
            )
56
        );
57
58
        if (!empty($document)) {
59
            return $document;
60
        }
61
62
        return null;
63
    }
64
}
65