Completed
Push — master ( b8b518...903aaa )
by Laurent
03:24
created

OrdersRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 43.9 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLast() 0 7 1
A getLastOrder() 9 9 1
A getLastDelivery() 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
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
7
/**
8
 * OrdersRepository
9
 *
10
 * This class was generated by the Doctrine ORM. Add your own custom
11
 * repository methods below.
12
 */
13
class OrdersRepository extends EntityRepository
14
{
15
    protected function getLast($count) {
16
        $query = $this->createQueryBuilder('o')
17
            ->orderBy('o.id', 'DESC')
18
            ->setMaxResults($count);
19
        
20
        return $query;
21
    }
22
    /**
23
     * Renvoi les dernières commandes.
24
     *
25
     * @param integer $count Nombre d'élément à afficher
26
     * @return array Query result
27
     */
28 View Code Duplication
    public function getLastOrder($count)
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...
29
    {
30
        $query = $this->getLast($count)
31
            ->where('o.orderdate < ' . date('d-m-Y'))
32
            ->andWhere('o.status = 1')
33
            ->getQuery();
34
35
        return $query->getResult();
36
    }
37
38
    /**
39
     * Renvoi les dernières commandes.
40
     *
41
     * @param integer $count Nombre d'élément à afficher
42
     * @return array Query result
43
     */
44 View Code Duplication
    public function getLastDelivery($count)
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...
45
    {
46
        $query = $this->getLast($count)
47
            ->where('o.delivdate >= ' . date('d-m-Y'))
48
            ->andWhere('o.status = 1')
49
            ->getQuery();
50
51
        return $query->getResult();
52
    }
53
}
54