Owner::setOwnedCars()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
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