Completed
Push — master ( bb86ee...4db16d )
by Loïc
02:12 queued 12s
created

AppUser::getEmailCanonical()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/*
4
 * This file is part of AppName.
5
 *
6
 * (c) Monofony
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Entity\User;
13
14
use Doctrine\ORM\Mapping as ORM;
15
use Sylius\Component\Customer\Model\CustomerInterface;
16
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
17
use Sylius\Component\User\Model\User as BaseUser;
18
19
/**
20
 * @ORM\Entity
21
 * @ORM\Table(name="sylius_app_user")
22
 */
23
class AppUser extends BaseUser implements AppUserInterface
24
{
25
    /**
26
     * @var CustomerInterface
27
     *
28
     * @ORM\OneToOne(targetEntity="Sylius\Component\Customer\Model\CustomerInterface", inversedBy="user", cascade={"persist"})
29
     * @ORM\JoinColumn(nullable=false)
30
     */
31
    private $customer;
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function getCustomer(): ?CustomerInterface
37
    {
38
        return $this->customer;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function setCustomer($customer): void
45
    {
46
        $this->customer = $customer;
47
    }
48
49
    /**
50
     * @return string|null
51
     */
52
    public function getEmail(): ?string
53
    {
54
        if (null === $this->customer) {
55
            return null;
56
        }
57
58
        return $this->customer->getEmail();
59
    }
60
61
    /**
62
     * @param string|null $email
63
     */
64
    public function setEmail(?string $email): void
65
    {
66
        if (null === $this->customer) {
67
            throw new UnexpectedTypeException($this->customer, CustomerInterface::class);
68
        }
69
70
        $this->customer->setEmail($email);
71
    }
72
73
    /**
74
     * @return string|null
75
     */
76
    public function getEmailCanonical(): ?string
77
    {
78
        if (null === $this->customer) {
79
            return null;
80
        }
81
82
        return $this->customer->getEmailCanonical();
83
    }
84
85
    /**
86
     * @param string|null $emailCanonical
87
     */
88
    public function setEmailCanonical(?string $emailCanonical): void
89
    {
90
        if (null === $this->customer) {
91
            throw new UnexpectedTypeException($this->customer, CustomerInterface::class);
92
        }
93
94
        $this->customer->setEmailCanonical($emailCanonical);
95
    }
96
}
97