Completed
Push — master ( 2fdc18...f6fd2e )
by Laurent
03:47
created

ArticleRepository::getStockAlert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 10
loc 10
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
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 getArticles()
33
    {
34
        $query = $this->createQueryBuilder('a')
35
            ->leftjoin('a.supplier', 's')
36
            ->addSelect('s')
37
            ->where('a.active = 1')
38
            ->orderBy('a.name', 'ASC');
39
        
40
        return $query;
41
    }
42
43
    /**
44
     * Affiche les articles actifs.
45
     *
46
     * @return array
47
     */
48
    public function getResultArticles()
49
    {
50
        $query = $this->getArticles()->getQuery();
51
        
52
        return $query->getResult();
53
    }
54
55
    /**
56
     * Renvoi les article du fournisseur en paramètre.
57
     *
58
     * @param int $supplier Supplier_id
59
     *
60
     * @return array Query result
61
     */
62 View Code Duplication
    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...
63
    {
64
        $query = $this->createQueryBuilder('a')
65
            ->where('a.active = true')
66
            ->andWhere('a.supplier = :id')
67
            ->setParameter('id', $supplier)
68
            ->orderBy('a.name', 'ASC')
69
            ->getQuery();
70
71
        return $query->getResult();
72
    }
73
74 View Code Duplication
    public function getStockAlert($count) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
75
        $query = $this->createQueryBuilder('a')
76
            ->where('a.active = true')
77
            ->andWhere('a.quantity < a.minstock')
78
            ->orderBy('a.name', 'ASC')
79
            ->setMaxResults($count)
80
            ->getQuery();
81
82
        return $query->getResult();
83
    }
84
}
85