Product   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 95
rs 10
c 0
b 0
f 0
wmc 12

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDescription() 0 3 1
A getMedias() 0 3 1
A getTitle() 0 3 1
A getId() 0 3 1
A getUrl() 0 3 1
A addMedia() 0 8 2
A setUrl() 0 5 1
A setDescription() 0 5 1
A removeMedia() 0 5 1
A setTitle() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the AutoFormBundle package.
7
 *
8
 * (c) David ALLIX <http://a2lix.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace A2lix\AutoFormBundle\Tests\Fixtures\Entity;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
use Doctrine\ORM\Mapping as ORM;
19
20
/**
21
 * @ORM\Entity
22
 */
23
class Product
24
{
25
    /**
26
     * @ORM\Id
27
     * @ORM\Column(type="integer")
28
     * @ORM\GeneratedValue(strategy="AUTO")
29
     */
30
    protected $id;
31
32
    /**
33
     * @ORM\Column(nullable=true)
34
     */
35
    protected $title;
36
37
    /**
38
     * @ORM\Column(type="text", nullable=true)
39
     */
40
    protected $description;
41
42
    /**
43
     * @ORM\Column(nullable=true)
44
     */
45
    protected $url;
46
47
    /**
48
     * @ORM\OneToMany(targetEntity="Media", mappedBy="product", cascade={"all"}, orphanRemoval=true)
49
     */
50
    protected $medias;
51
52
    public function __construct()
53
    {
54
        $this->medias = new ArrayCollection();
55
    }
56
57
    public function getId(): ?int
58
    {
59
        return $this->id;
60
    }
61
62
    public function getTitle(): ?string
63
    {
64
        return $this->title;
65
    }
66
67
    public function setTitle(?string $title): self
68
    {
69
        $this->title = $title;
70
71
        return $this;
72
    }
73
74
    public function getDescription(): ?string
75
    {
76
        return $this->description;
77
    }
78
79
    public function setDescription(?string $description): self
80
    {
81
        $this->description = $description;
82
83
        return $this;
84
    }
85
86
    public function getUrl(): ?string
87
    {
88
        return $this->url;
89
    }
90
91
    public function setUrl(?string $url): self
92
    {
93
        $this->url = $url;
94
95
        return $this;
96
    }
97
98
    public function getMedias(): Collection
99
    {
100
        return $this->medias;
101
    }
102
103
    public function addMedia(Media $media): self
104
    {
105
        if (!$this->medias->contains($media)) {
106
            $media->setProduct($this);
107
            $this->medias->add($media);
108
        }
109
110
        return $this;
111
    }
112
113
    public function removeMedia(Media $media): self
114
    {
115
        $this->medias->removeElement($media);
116
117
        return $this;
118
    }
119
}
120