Completed
Push — wip-platform ( 50ba02...c03fc2 )
by
unknown
29:01
created

OwningSideRelationHandlerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateRelation() 0 10 2
1
<?php
2
3
/*
4
 * Copyright (C) 2015-2017 Libre Informatique
5
 *
6
 * This file is licenced under the GNU LGPL v3.
7
 * For the full copyright and license information, please view the LICENSE.md
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Blast\Bundle\CoreBundle\Doctrine\ORM;
12
13
use Blast\Bundle\CoreBundle\Tools\Reflection\ClassAnalyzer;
14
15
trait OwningSideRelationHandlerTrait
16
{
17
    public function updateRelation($owning, $action = 'set')
18
    {
19
        $rc = new \ReflectionClass($this);
20
        $setter = $action . $rc->getShortName();
21
22
        $owning_rc = new \ReflectionClass($owning);
23
        if (ClassAnalyzer::hasMethod($owning_rc, $setter)) {
24
            $owning->$setter($this);
25
        }
26
    }
27
}
28