UnitRepository::findById()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace AppBundle\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use Domain\Unit\Enitity\UnitInterface;
7
use Domain\Unit\Repository\UnitRepositoryInterface;
8
9
/**
10
 * UnitRepository
11
 *
12
 * This class was generated by the Doctrine ORM. Add your own custom
13
 * repository methods below.
14
 */
15
class UnitRepository extends EntityRepository implements UnitRepositoryInterface
16
{
17
    /**
18
     * @param UnitInterface $unit
19
     * @return void
20
     */
21
    public function add(UnitInterface $unit)
22
    {
23
        $this->_em->persist($unit);
24
        $this->_em->flush();
25
    }
26
27
    /**
28
     * @param integer $id
29
     * @return UnitInterface|null
30
     */
31
    public function findById($id)
32
    {
33
        return $this->findOneBy(['id' => $id]);
34
    }
35
36
    /**
37
     * @param UnitInterface $unit
38
     * @return void
39
     */
40
    public function update(UnitInterface $unit)
41
    {
42
        $this->_em->persist($unit);
43
        $this->_em->flush();
44
    }
45
}
46