Completed
Push — master ( 80f2c6...3ec183 )
by Laurent
03:15
created

ArticleRepository::getAllArticles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
/**
4
 * Entité Article.
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    since 1.0.0
13
 *
14
 * @link       https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Entity;
17
18
use Doctrine\ORM\EntityRepository;
19
20
/**
21
 * ArticleRepository.
22
 *
23
 * @category   Entity
24
 */
25
class ArticleRepository extends EntityRepository
26
{
27
    /**
28
     * Affiche les articles actifs.
29
     *
30
     * @return QueryBuilder Requête DQL
31
     */
32 View Code Duplication
    public function getAllArticles()
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...
33
    {
34
        $query = $this->createQueryBuilder('a')
35
            ->join('a.supplier', 's')
36
            ->addSelect('s')
37
            ->where('s.active = 1')
38
            ->join('a.familyLog', 'fl')
39
            ->addSelect('fl')
40
            ->join('a.zoneStorages', 'z')
41
            ->addSelect('z')
42
        ;
43
        
44
        return $query;
45
    }
46
47
    /**
48
     * Affiche les articles actifs.
49
     *
50
     * @return QueryBuilder Requête DQL
51
     */
52 View Code Duplication
    public function getArticles()
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...
53
    {
54
        $query = $this->createQueryBuilder('a')
55
            ->join('a.supplier', 's')
56
            ->addSelect('s')
57
            ->where('s.active = 1')
58
            ->join('a.familyLog', 'fl')
59
            ->addSelect('fl')
60
            ->join('a.zoneStorages', 'z')
61
            ->addSelect('z')
62
            ->where('a.active = 1')
63
        ;
64
        
65
        return $query;
66
    }
67
68
    /**
69
     * Affiche les articles actifs.
70
     *
71
     * @return array Query result
72
     */
73
    public function getResultArticles()
74
    {
75
        $query = $this->getArticles()->getQuery();
76
        
77
        return $query->getResult();
78
    }
79
80
    /**
81
     * Renvoi les article du fournisseur en paramètre.
82
     *
83
     * @param int $supplier Supplier_id
84
     *
85
     * @return array Query result
86
     */
87
    public function getArticleFromSupplier($supplier)
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...
88
    {
89
        $query = $this->createQueryBuilder('a')
90
            ->where('a.active = true')
91
            ->andWhere('a.supplier = :id')
92
            ->setParameter('id', $supplier)
93
            ->orderBy('a.name', 'ASC')
94
            ->getQuery();
95
96
        return $query->getResult();
97
    }
98
99
    /**
100
     * Renvoi les articles en stock d'alerte.
101
     *
102
     * @param integer $count Nombre d'élément à afficher
103
     * @return array Query result
104
     */
105
    public function getStockAlert($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...
106
    {
107
        $query = $this->createQueryBuilder('a')
108
            ->where('a.active = true')
109
            ->andWhere('a.quantity < a.minstock')
110
            ->orderBy('a.name', 'ASC')
111
            ->setMaxResults($count)
112
            ->getQuery();
113
114
        return $query->getResult();
115
    }
116
}
117