CarOwner::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Test\TestBundle\Entity;
3
4
use Tpg\ExtjsBundle\Annotation as Extjs;
5
use Doctrine\ORM\Mapping as ORM;
6
use JMS\Serializer\Annotation as JMS;
7
use \Test\TestBundle\Entity\Car;
8
9
/**
10
 * @Extjs\Model
11
 * @Extjs\ModelProxy("/mycarowners")
12
 * @ORM\Entity
13
 * @ORM\Table(name="car_owner")
14
 */
15
class CarOwner {
16
    /**
17
     * @ORM\Id
18
     * @ORM\Column(type="integer")
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     * @JMS\Type("integer")
21
     */
22
    protected $id;
23
24
    /**
25
     * @ORM\Column(type="string")
26
     * @JMS\Type("string")
27
     */
28
    protected $name;
29
30
    /**
31
     * @ORM\OneToMany(targetEntity="Test\TestBundle\Entity\Car", mappedBy="carOwner")
32
     * @JMS\Type("ArrayCollection<Test\TestBundle\Entity\Car>")
33
     */
34
    protected $cars;
35
36
    /**
37
     * Constructor
38
     */
39 10
    public function __construct()
40
    {
41 10
        $this->cars = new \Doctrine\Common\Collections\ArrayCollection();
42 10
    }
43
    
44
    /**
45
     * Get id
46
     *
47
     * @return integer 
48
     */
49 5
    public function getId()
50
    {
51 5
        return $this->id;
52
    }
53
54
    /**
55
     * Set name
56
     *
57
     * @param string $name
58
     * @return CarOwner
59
     */
60 10
    public function setName($name)
61
    {
62 10
        $this->name = $name;
63
    
64 10
        return $this;
65
    }
66
67
    /**
68
     * Get name
69
     *
70
     * @return string 
71
     */
72 1
    public function getName()
73
    {
74 1
        return $this->name;
75
    }
76
77
    /**
78
     * Add cars
79
     *
80
     * @param Car $cars
81
     * @return CarOwner
82
     */
83 10
    public function addCar(Car $cars)
84
    {
85 10
        $this->cars[] = $cars;
86 10
        $cars->setCarOwner($this);
87 10
        return $this;
88
    }
89
90
    /**
91
     * Remove cars
92
     *
93
     * @param Car                         $cars
94
     */
95
    public function removeCar(Car $cars)
96
    {
97
        $this->cars->removeElement($cars);
98
        $cars->setCarOwner(null);
99
    }
100
101
    /**
102
     * Get cars
103
     *
104
     * @return \Doctrine\Common\Collections\Collection 
105
     */
106
    public function getCars()
107
    {
108
        return $this->cars;
109
    }
110
}