Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

SupplierRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllItems() 0 9 1
A getItems() 0 8 1
A getSupplierForReassign() 0 13 1
1
<?php
2
3
/**
4
 * Entity Supplier.
5
 *
6
 * PHP Version 7
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 GIT: <git_id>
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
namespace App\Repository\Settings;
17
18
use Doctrine\ORM\EntityRepository;
19
20
/**
21
 * SupplierRepository Entity.
22
 *
23
 * @category Entity
24
 */
25
class SupplierRepository extends EntityRepository
26
{
27
    /**
28
     * Displays all suppliers.
29
     *
30
     * @return \Doctrine\ORM\QueryBuilder Requête DQL
31
     */
32
    public function getAllItems()
33
    {
34
        $query = $this->createQueryBuilder('s')
35
            ->join('s.familyLog', 'fl')
36
            ->addSelect('fl')
37
        ;
38
        
39
        return $query;
40
    }
41
42
43
    /**
44
     * Displays active suppliers.
45
     *
46
     * @return \Doctrine\ORM\QueryBuilder Requête DQL
47
     */
48
    public function getItems()
49
    {
50
        $query = $this->getAllItems()
51
            ->where('s.active = 1')
52
        ;
53
        
54
        return $query;
55
    }
56
57
    /**
58
     * Returns the active suppliers matching logistic family of the article in parameter.
59
     *
60
     * @param App\Entity\Settings\Supplier $supplier Selected supplier
61
     *
62
     * @return \Doctrine\ORM\QueryBuilder Requête DQL
63
     */
64
    public function getSupplierForReassign($supplier)
65
    {
66
        $query = $this->createQueryBuilder('s');
67
        $query
68
            ->select('s')
69
            ->where($query->expr()->neq('s.name', ':idname'))
70
            ->andWhere('s.familyLog = :flname')
71
            ->andWhere('s.active = true')
72
            ->setParameters(['idname' => $supplier->getName(), 'flname' => $supplier->getFamilyLog(),])
73
            ->orderBy('s.name', 'ASC');
74
75
        return $query;
76
    }
77
}
78