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

Owner::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

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