OneToOneRelation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 0
cbo 1
dl 29
loc 29
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 1
A getEntity() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Ajir\RabbitMqSqlBundle\Model;
3
4
use Ajir\RabbitMqSqlBundle\DataMapper\DataMapper;
5
use Ajir\RabbitMqSqlBundle\DataTransformer\DataTransformer;
6
7
/**
8
 * Class OneToOneRelation
9
 *
10
 * @author Florian Ajir <[email protected]>
11
 */
12 View Code Duplication
class OneToOneRelation 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