ItemCollection::setItem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use Assert\AssertionFailedException;
8
use Ramsey\Uuid\Uuid;
9
10
/**
11
 * @ORM\Table(name="item_collections")
12
 * @ORM\Entity(repositoryClass="App\Repository\ItemCollectionRepository")
13
 */
14
class ItemCollection
15
{
16
    /**
17
     * @ORM\Id()
18
     * @ORM\ManyToOne(targetEntity="App\Entity\Item", inversedBy="collections", cascade={"persist"})
19
     * @ORM\JoinColumn(name="item_id", referencedColumnName="id", nullable=false)
20
     */
21
    private $item;
22
23
    /**
24
     * @ORM\Id()
25
     * @ORM\ManyToOne(targetEntity="App\Entity\Collection", inversedBy="items", cascade={"persist"})
26
     * @ORM\JoinColumn(name="collection_id", referencedColumnName="id", nullable=false)
27
     */
28
    private $collection;
29
30
    /**
31
     * @param Item $item
32
     * @param Collection $collection
33
     * @throws \Assert\AssertionFailedException
34
     */
35 2
    public function __construct(Item $item, Collection $collection)
36
    {
37 2
        $this->setItem($item);
38 2
        $this->setCollection($collection);
39 2
    }
40
41
    /**
42
     * @return Item
43
     */
44 2
    public function getItem(): Item
45
    {
46 2
        return $this->item;
47
    }
48
49
    /**
50
     * @param Item $item
51
     * @return ItemCollection
52
     */
53 2
    public function setItem(Item $item): self
54
    {
55 2
        $this->item = $item;
56
57 2
        return $this;
58
    }
59
60
    /**
61
     * @return Collection
62
     */
63 2
    public function getCollection(): Collection
64
    {
65 2
        return $this->collection;
66
    }
67
68
    /**
69
     * @param Collection $collection
70
     * @return ItemCollection
71
     */
72 2
    public function setCollection(Collection $collection): self
73
    {
74 2
        $this->collection = $collection;
75
76 2
        return $this;
77
    }
78
}
79