OneToManyRelation   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 59
ccs 19
cts 19
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A getEntities() 0 4 1
A getReferences() 0 4 1
A isRemoveReferenced() 0 4 1
1
<?php
2
namespace Ajir\RabbitMqSqlBundle\Model;
3
4
use Ajir\RabbitMqSqlBundle\DataMapper\DataMapper;
5
use Ajir\RabbitMqSqlBundle\DataTransformer\DataTransformer;
6
7
/**
8
 * Class OneToManyRelation
9
 *
10
 * @author Florian Ajir <[email protected]>
11
 */
12
class OneToManyRelation extends AbstractRelation implements RelationInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $entities;
18
19
    /**
20
     * @var array
21
     */
22
    protected $references;
23
24
    /**
25
     * @var bool
26
     */
27
    protected $removeReferenced;
28
29
    /**
30
     * @param array $data
31
     */
32 4
    public function __construct(array $data)
33
    {
34 4
        parent::__construct($data);
35 4
        $relation = $data[DataTransformer::RELATED_RELATION_KEY];
36 4
        $joinColumn = $relation[DataMapper::RELATION_KEY_JOIN_COLUMN];
37 4
        $this->joinColumnName = $joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_NAME];
38 4
        $this->joinColumnReferencedColumnName =
39 4
            $joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME];
40 4
        $this->entities = $data[DataTransformer::RELATED_DATA_KEY];
41 4
        $this->references = isset($relation[DataMapper::REFERENCES_KEY]) ?
42 4
            $relation[DataMapper::REFERENCES_KEY] : array();
43 4
        $this->removeReferenced = isset($relation[DataMapper::REMOVE_REFERENCED_KEY])
44 1
            && $relation[DataMapper::REMOVE_REFERENCED_KEY] == 'true';
45 4
    }
46
47
    /**
48
     * @return array
49
     */
50 2
    public function getEntities()
51
    {
52 2
        return $this->entities;
53
    }
54
55
    /**
56
     * @return array
57
     */
58 2
    public function getReferences()
59
    {
60 2
        return $this->references;
61
    }
62
63
    /**
64
     * @return boolean
65
     */
66 3
    public function isRemoveReferenced()
67
    {
68 3
        return $this->removeReferenced;
69
    }
70
}
71