Completed
Push — feature/middleware ( a35412...bb427e )
by Derek Stephen
03:50
created

DragonRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 8 2
A delete() 0 5 1
1
<?php
2
3
namespace BoneMvc\Module\Dragon\Repository;
4
5
use BoneMvc\Module\Dragon\Entity\Dragon;
6
use Doctrine\ORM\EntityRepository;
7
8
class DragonRepository extends EntityRepository
9
{
10
    /**
11
     * @param Dragon $dragon
12
     * @return $dragon
0 ignored issues
show
Documentation introduced by
The doc-type $dragon could not be parsed: Unknown type name "$dragon" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
13
     * @throws \Doctrine\ORM\ORMException
14
     * @throws \Doctrine\ORM\OptimisticLockException
15
     */
16
    public function save(Dragon $dragon)
17
    {
18
        if(!$dragon->getID()) {
19
            $this->_em->persist($dragon);
20
        }
21
        $this->_em->flush($dragon);
22
        return $dragon;
23
    }
24
25
    /**
26
     * @param Dragon $dragon
27
     * @throws \Doctrine\ORM\OptimisticLockException
28
     * @throws \Doctrine\ORM\ORMException
29
     */
30
    public function delete(Dragon $dragon)
31
    {
32
        $this->_em->remove($dragon);
33
        $this->_em->flush($dragon);
34
    }
35
}
36