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

User   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getStores() 0 3 1
A addStore() 0 3 1
A setStores() 0 5 2
A getId() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace Xsolve\LegacyAssociateTests\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