Completed
Push — master ( 630db2...59081b )
by Laurent
03:27
created

ArticleRepository::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 11
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
    public function getAllItems()
33
    {
34
        $query = $this->createQueryBuilder('a')
35
            ->join('a.supplier', 's')
36
            ->addSelect('s')
37
            ->join('a.familyLog', 'fl')
38
            ->addSelect('fl')
39
            ->join('a.zoneStorages', 'z')
40
            ->addSelect('z')
41
        ;
42
        
43
        return $query;
44
    }
45
46
    /**
47
     * Affiche les articles actifs.
48
     *
49
     * @return QueryBuilder Requête DQL
50
     */
51
    public function getItems()
52
    {
53
        $query = $this->createQueryBuilder('a')
54
            ->join('a.supplier', 's')
55
            ->addSelect('s')
56
            ->where('s.active = 1')
57
            ->join('a.familyLog', 'fl')
58
            ->addSelect('fl')
59
            ->join('a.zoneStorages', 'z')
60
            ->addSelect('z')
61
            ->where('a.active = 1')
62
        ;
63
        
64
        return $query;
65
    }
66
67
    /**
68
     * Affiche les articles actifs.
69
     *
70
     * @return array Query result
71
     */
72
    public function getResultArticles()
73
    {
74
        $query = $this->getItems()->getQuery();
75
        
76
        return $query->getResult();
77
    }
78
79
    /**
80
     * Renvoi les article du fournisseur en paramètre.
81
     *
82
     * @param int $supplier Supplier_id
83
     *
84
     * @return array Query result
85
     */
86
    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...
87
    {
88
        $query = $this->createQueryBuilder('a')
89
            ->where('a.active = true')
90
            ->andWhere('a.supplier = :id')
91
            ->setParameter('id', $supplier)
92
            ->orderBy('a.name', 'ASC')
93
            ->getQuery();
94
95
        return $query->getResult();
96
    }
97
98
    /**
99
     * Renvoi les articles en stock d'alerte.
100
     *
101
     * @param integer $count Nombre d'élément à afficher
102
     * @return array Query result
103
     */
104
    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...
105
    {
106
        $query = $this->createQueryBuilder('a')
107
            ->where('a.active = true')
108
            ->andWhere('a.quantity < a.minstock')
109
            ->orderBy('a.name', 'ASC')
110
            ->setMaxResults($count)
111
            ->getQuery();
112
113
        return $query->getResult();
114
    }
115
}
116