BalanceRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A findOneByUser() 0 4 1
A findOneBy() 0 4 1
1
<?php
2
 
3
namespace JhFlexiTime\Repository;
4
 
5
use Doctrine\Common\Persistence\ObjectRepository;
6
use ZfcUser\Entity\UserInterface;
7
use JhFlexiTime\Entity\RunningBalance;
8
use Doctrine\Common\Persistence\ObjectManager;
9
10
/**
11
 * Class BalanceRepository
12
 * @package JhFlexiTime\Repository
13
 * @author Aydin Hassan <[email protected]>
14
 */
15
class BalanceRepository implements BalanceRepositoryInterface
16
{
17
 
18
    /**
19
     * @var ObjectRepository
20
     */
21
    protected $balanceRepository;
22
23
    /**
24
     * @var ObjectManager
25
     */
26
    protected $objectManager;
27
28
    /**
29
     * @param ObjectRepository $balanceRepository
30
     * @param ObjectManager $objectManager
31
     */
32
    public function __construct(ObjectRepository $balanceRepository, ObjectManager $objectManager)
33
    {
34
        $this->balanceRepository    = $balanceRepository;
35
        $this->objectManager        = $objectManager;
36
    }
37
38
    /**
39
     * Get a User's running balance,
40
     * if it does not exist, create it
41
     *
42
     * @param UserInterface $user
43
     * @return \JhFlexiTime\Entity\RunningBalance
44
     */
45
    public function findOneByUser(UserInterface $user)
46
    {
47
        return $this->balanceRepository->findOneBy(['user' => $user]);
48
    }
49
50
    /**
51
     * Proxy to Doctrine Repo
52
     *
53
     * @param array $criteria
54
     * @return \JhFlexiTime\Entity\RunningBalance
55
     */
56
    public function findOneBy(array $criteria)
57
    {
58
        return $this->balanceRepository->findOneBy($criteria);
59
    }
60
}
61