Completed
Push — Recipes ( c1a0bd...9ec83f )
by Laurent
24:17
created

SettingsRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 42
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllItems() 7 7 1
A getItems() 6 6 1
A findFirst() 9 9 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
 * Entité Settings.
5
 *
6
 * PHP Version 5
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2014 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: <git_id>
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Repository\Settings;
17
18
use Doctrine\ORM\EntityRepository;
19
20
/**
21
 * SettingsRepository Entité Settings.
22
 *
23
 * @category Entity
24
 */
25 View Code Duplication
class SettingsRepository extends EntityRepository
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...
26
{
27
    /**
28
     * Affiche toutes les configurations.
29
     *
30
     * @return QueryBuilder Requête DQL
31
     */
32
    public function getAllItems()
33
    {
34
        $query = $this->createQueryBuilder('s')
35
            ->getQuery()->getResult();
36
37
        return $query;
38
    }
39
40
    /**
41
     * Affiche les configurations actives.
42
     *
43
     * @return QueryBuilder Requête DQL
44
     */
45
    public function getItems()
46
    {
47
        $query = $this->getAllItems();
48
49
        return $query;
50
    }
51
52
    /**
53
     * Affiche le premier enregistrement.
54
     *
55
     * @return QueryBuilder Requête DQL
56
     */
57
    public function findFirst()
58
    {
59
        $query = $this->createQueryBuilder('s')
60
            ->setMaxResults(1)
61
            ->orderBy('s.id', 'ASC')
62
            ->getQuery()->getSingleResult();
63
64
            return $query;
65
    }
66
}
67