Passed
Pull Request — master (#9)
by Mariusz
02:39
created

Category   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A setName() 0 3 1
A getProducts() 0 3 1
A __construct() 0 5 1
A getName() 0 3 1
A setProducts() 0 5 2
1
<?php
2
3
namespace Xsolve\AssociateTests\Functional\DoctrineOrm\Mock\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping\Entity;
8
use Doctrine\ORM\Mapping\Id;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Table;
11
use Doctrine\ORM\Mapping\OneToMany;
12
13
/**
14
 * @Entity
15
 * @Table(name="category")
16
 */
17
class Category
18
{
19
    /**
20
     * @var string
21
     *
22
     * @Id
23
     * @Column(type="string", length=64)
24
     */
25
    protected $id;
26
27
    /**
28
     * @var string
29
     *
30
     * @Column(type="string", length=128)
31
     */
32
    protected $name;
33
34
    /**
35
     * @var Collection|Product[]
36
     *
37
     * @OneToMany(targetEntity="Product", mappedBy="category")
38
     */
39
    protected $products;
40
41
    /**
42
     * @param string $id
43
     */
44
    public function __construct(string $id)
45
    {
46
        $this->id = $id;
47
48
        $this->products = new ArrayCollection();
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getId(): string
55
    {
56
        return $this->id;
57
    }
58
59
    /**
60
     * @param string $name
61
     */
62
    public function setName(string $name)
63
    {
64
        $this->name = $name;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getName(): string
71
    {
72
        return $this->name;
73
    }
74
75
    /**
76
     * @param Product[] $products
77
     */
78
    public function setProducts(array $products)
79
    {
80
        $this->products->clear();
81
        foreach ($products as $product) {
82
            $this->products->add($product);
83
        }
84
    }
85
86
    /**
87
     * @return Collection|Product[]
88
     */
89
    public function getProducts(): Collection
90
    {
91
        return $this->products;
92
    }
93
}
94