Completed
Push — master ( f496a8...4f1947 )
by Sebastien
03:00 queued 01:27
created

Owner   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 1
dl 62
loc 62
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 2
A getId() 4 4 1
A setName() 4 4 1
A getName() 4 4 1
A setOwnedCars() 7 7 2
A getOwnedCars() 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
3
namespace Khepin\Fixture\Document;
4
5
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
6
use Doctrine\Common\Collections\ArrayCollection;
7
8
/**
9
 * @ODM\Document
10
 */
11 View Code Duplication
class Owner
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...
12
{
13
14
    /**
15
     * @ODM\Id
16
     */
17
    private $id;
18
19
    /**
20
     * @ODM\String
21
     */
22
    private $name;
23
24
    /**
25
     * @ODM\ReferenceMany(targetDocument="Car")
26
     * @var ArrayCollection
27
     */
28
    private $owned_cars;
29
30
    public function __construct($name = null, Car $car = null)
31
    {
32
        $this->owned_cars = new ArrayCollection();
33
        $this->name = $name;
34
        if ($car) {
35
            $this->owned_cars->add($car);
36
        }
37
    }
38
39
    public function getId()
40
    {
41
        return $this->id;
42
    }
43
44
    public function setName($name)
45
    {
46
        $this->name = $name;
47
    }
48
49
    public function getName()
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * @param ArrayCollection $ownedCars
56
     */
57
    public function setOwnedCars($ownedCars)
58
    {
59
        $this->owned_cars = new ArrayCollection();
60
        foreach ($ownedCars as $car) {
61
            $this->owned_cars->add($car);
62
        }
63
    }
64
65
    /**
66
     * @return ArrayCollection
67
     */
68
    public function getOwnedCars()
69
    {
70
        return $this->owned_cars;
71
    }
72
}
73