EntityRepositoryTrait   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 77
rs 10
c 1
b 0
f 0
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDonorRepository() 0 9 2
A getCityRepository() 0 9 2
A getDistrictRepository() 0 9 2
A getUserRepository() 0 9 2
A getVariableRepository() 0 9 2
1
<?php
2
/**
3
 * @package    EBloodBank
4
 * @subpackage Traits
5
 * @since      1.6
6
 */
7
namespace EBloodBank\Traits;
8
9
/**
10
 * Helper methods to get the repository of the application entities.
11
 *
12
 * @since 1.6
13
 */
14
trait EntityRepositoryTrait
15
{
16
    use EntityManagerTrait;
17
18
    /**
19
     * @return \EBloodBank\Models\UserRepository
20
     * @since  1.6
21
     */
22
    public function getUserRepository()
23
    {
24
        static $repository = null;
25
26
        if (is_null($repository)) {
27
            $repository = $this->getEntityManager()->getRepository('Entities:User');
28
        }
29
30
        return $repository;
31
    }
32
33
    /**
34
     * @return \EBloodBank\Models\CityRepository
35
     * @since  1.6
36
     */
37
    public function getCityRepository()
38
    {
39
        static $repository = null;
40
41
        if (is_null($repository)) {
42
            $repository = $this->getEntityManager()->getRepository('Entities:City');
43
        }
44
45
        return $repository;
46
    }
47
48
    /**
49
     * @return \EBloodBank\Models\DistrictRepository
50
     * @since  1.6
51
     */
52
    public function getDistrictRepository()
53
    {
54
        static $repository = null;
55
56
        if (is_null($repository)) {
57
            $repository = $this->getEntityManager()->getRepository('Entities:District');
58
        }
59
60
        return $repository;
61
    }
62
63
    /**
64
     * @return \EBloodBank\Models\DonorRepository
65
     * @since  1.6
66
     */
67
    public function getDonorRepository()
68
    {
69
        static $repository = null;
70
71
        if (is_null($repository)) {
72
            $repository = $this->getEntityManager()->getRepository('Entities:Donor');
73
        }
74
75
        return $repository;
76
    }
77
78
    /**
79
     * @return \EBloodBank\Models\VariableRepository
80
     * @since  1.6
81
     */
82
    public function getVariableRepository()
83
    {
84
        static $repository = null;
85
86
        if (is_null($repository)) {
87
            $repository = $this->getEntityManager()->getRepository('Entities:Variable');
88
        }
89
90
        return $repository;
91
    }
92
}
93