Completed
Push — master ( 4be90b...11f63d )
by Laurent
12:32 queued 08:08
created

OrdersRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 57.89 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 22
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getLastOrder() 11 11 1
A getLastDelivery() 11 11 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
    /**
16
     * Renvoi les dernières commandes.
17
     *
18
     * @param integer $count Nombre d'élément à afficher
19
     * @return array Query result
20
     */
21 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...
22
    {
23
        $query = $this->createQueryBuilder('o')
24
            ->where('o.status = 1')
25
            ->andWhere('o.delivdate < ' . date('d-m-Y'))
26
            ->orderBy('o.id', 'DESC')
27
            ->setMaxResults($count)
28
            ->getQuery();
29
30
        return $query->getResult();
31
    }
32
33
    /**
34
     * Renvoi les dernières commandes.
35
     *
36
     * @param integer $count Nombre d'élément à afficher
37
     * @return array Query result
38
     */
39 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...
40
    {
41
        $query = $this->createQueryBuilder('o')
42
            ->where('o.status = 1')
43
            ->andWhere('o.delivdate >= ' . date('d-m-Y'))
44
            ->orderBy('o.id', 'DESC')
45
            ->setMaxResults($count)
46
            ->getQuery();
47
48
        return $query->getResult();
49
    }
50
}
51