Passed
Pull Request — master (#181)
by Mathieu
02:31
created

Variant   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 17
c 1
b 0
f 0
dl 0
loc 81
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A setImage() 0 3 1
A getImage() 0 3 1
A getId() 0 3 1
A getPrePersistedId() 0 3 1
A setPrePersistedId() 0 3 1
A setProduct() 0 3 1
A generatePrePersist() 0 4 2
A getProduct() 0 3 1
A setName() 0 3 1
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Fixtures\Entity\Cascade;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\Table(name="variant_cascade")
10
 * @ORM\HasLifecycleCallbacks
11
 */
12
class Variant
13
{
14
    /**
15
     * @ORM\Id
16
     * @ORM\GeneratedValue
17
     * @ORM\Column(type="integer")
18
     */
19
    private $id;
20
21
    /**
22
     * @ORM\Column(type="integer", nullable=true)
23
     */
24
    private $prePersistedId;
25
26
    /**
27
     * @ORM\Column(type="string", length=255)
28
     */
29
    private $name;
30
31
    /**
32
     * @ORM\ManyToOne(targetEntity=Product::class, inversedBy="variants")
33
     */
34
    private $product;
35
36
    /**
37
     * @ORM\OneToOne(targetEntity=Image::class, cascade={"persist"})
38
     */
39
    private $image;
40
41
    public function getId(): ?int
42
    {
43
        return $this->id;
44
    }
45
46
    public function getPrePersistedId(): ?int
47
    {
48
        return $this->prePersistedId;
49
    }
50
51
    public function setPrePersistedId(?int $prePersistedId): void
52
    {
53
        $this->prePersistedId = $prePersistedId;
54
    }
55
56
    public function getName(): ?string
57
    {
58
        return $this->name;
59
    }
60
61
    public function setName(?string $name): void
62
    {
63
        $this->name = $name;
64
    }
65
66
    public function getProduct(): ?Product
67
    {
68
        return $this->product;
69
    }
70
71
    public function setProduct(Product $product): void
72
    {
73
        $this->product = $product;
74
    }
75
76
    public function getImage(): ?Image
77
    {
78
        return $this->image;
79
    }
80
81
    public function setImage(Image $image): void
82
    {
83
        $this->image = $image;
84
    }
85
86
    /**
87
     * @ORM\PrePersist
88
     */
89
    public function generatePrePersist()
90
    {
91
        if (null !== $this->image) {
92
            $this->image->setPrePersistedId($this->image->getId());
93
        }
94
    }
95
}
96