Completed
Pull Request — master (#10)
by Mariusz
03:23
created

User::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Table;
9
use Doctrine\ORM\Mapping\Id;
10
use Doctrine\ORM\Mapping\Column;
11
use Doctrine\ORM\Mapping\OneToMany;
12
13
/**
14
 * @Entity
15
 * @Table(name="user")
16
 */
17
class User
18
{
19
    /**
20
     * @var string
21
     *
22
     * @Id
23
     * @Column(type="string", length=64)
24
     */
25
    protected $id;
26
27
    /**
28
     * @var Collection|Store[]
29
     *
30
     * @OneToMany(targetEntity="Store", mappedBy="user")
31
     */
32
    protected $stores;
33
34
    /**
35
     * @param string $id
36
     */
37
    public function __construct(string $id)
38
    {
39
        $this->id = $id;
40
41
        $this->stores = new ArrayCollection();
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getId(): string
48
    {
49
        return $this->id;
50
    }
51
52
    /**
53
     * @param Store[] $stores
54
     */
55
    public function setStores(array $stores)
56
    {
57
        $this->stores->clear();
58
        foreach ($stores as $store) {
59
            $this->stores->add($store);
60
        }
61
    }
62
63
    /**
64
     * @param Store $store
65
     */
66
    public function addStore(Store $store)
67
    {
68
        $this->stores->add($store);
69
    }
70
71
    /**
72
     * @return Collection|Store[]
73
     */
74
    public function getStores(): Collection
75
    {
76
        return $this->stores;
77
    }
78
}
79