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

Variant::getImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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