Owner   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 64
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 64
loc 64
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\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\Common\Collections\ArrayCollection;
7
8
/**
9
 * @ORM\Entity()
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
     * @ORM\Column(name="id", type="integer")
16
     * @ORM\Id
17
     * @ORM\GeneratedValue(strategy="AUTO")
18
     */
19
    private $id;
20
21
    /**
22
     * @ORM\Column(type="string")
23
     */
24
    private $name;
25
26
    /**
27
     * @ORM\OneToMany(targetEntity="Car", mappedBy="owner")
28
     * @var ArrayCollection
29
     */
30
    private $owned_cars;
31
32
    public function __construct($name = null, Car $car = null)
33
    {
34
        $this->owned_cars = new ArrayCollection();
35
        $this->name = $name;
36
        if ($car) {
37
            $this->owned_cars->add($car);
38
        }
39
    }
40
41
    public function getId()
42
    {
43
        return $this->id;
44
    }
45
46
    public function setName($name)
47
    {
48
        $this->name = $name;
49
    }
50
51
    public function getName()
52
    {
53
        return $this->name;
54
    }
55
56
    /**
57
     * @param ArrayCollection $ownedCars
58
     */
59
    public function setOwnedCars($ownedCars)
60
    {
61
        $this->owned_cars = new ArrayCollection();
62
        foreach ($ownedCars as $car) {
63
            $this->owned_cars->add($car);
64
        }
65
    }
66
67
    /**
68
     * @return ArrayCollection
69
     */
70
    public function getOwnedCars()
71
    {
72
        return $this->owned_cars;
73
    }
74
}
75