ManyToOneRelation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 1
Metric Value
dl 10
loc 10
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
crap 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 ManyToOneRelation
9
 *
10
 * @author Florian Ajir <[email protected]>
11
 */
12 View Code Duplication
class ManyToOneRelation extends AbstractRelation implements RelationInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $entity;
18
19
    /**
20
     * @param array $data
21
     */
22 2
    public function __construct(array $data)
23
    {
24 2
        parent::__construct($data);
25 2
        $relation = $data[DataTransformer::RELATED_RELATION_KEY];
26 2
        $joinColumn = $relation[DataMapper::RELATION_KEY_JOIN_COLUMN];
27 2
        $this->joinColumnName = $joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_NAME];
28 2
        $this->joinColumnReferencedColumnName =
29 2
            $joinColumn[DataMapper::RELATION_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME];
30 2
        $this->entity = $data[DataTransformer::RELATED_DATA_KEY][$this->entityName];
31 2
    }
32
33
    /**
34
     * @return array
35
     */
36 1
    public function getEntity()
37
    {
38 1
        return $this->entity;
39
    }
40
}
41