Domain::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the mailserver-admin package.
6
 * (c) Jeffrey Boehm <https://github.com/jeboehm/mailserver-admin>
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace App\Entity;
12
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Doctrine\Common\Collections\Collection;
15
use Doctrine\ORM\Mapping as ORM;
16
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
17
use Symfony\Component\Validator\Constraints as Assert;
18
19
/**
20
 * @ORM\Entity(repositoryClass="App\Repository\DomainRepository")
21
 * @ORM\Table(name="mail_domains")
22
 * @UniqueEntity("name")
23
 */
24
class Domain
25
{
26
    use DkimInfoTrait;
27
28
    /**
29
     * @ORM\Id()
30
     * @ORM\GeneratedValue()
31
     * @ORM\Column(type="integer", name="id")
32
     */
33
    private ?int $id = null;
34
35
    /**
36
     * @ORM\Column(type="string", name="name", unique=true, options={"collation":"utf8_unicode_ci"})
37
     * @Assert\NotBlank()
38
     */
39
    private string $name = '';
40
41
    /**
42
     * @ORM\Column(type="boolean", name="dkim_enabled")
43
     */
44
    private bool $dkimEnabled = false;
45
46
    /**
47
     * @ORM\Column(type="string", name="dkim_selector")
48
     * @Assert\Regex(pattern="/^[a-z0-9]{1,50}$/")
49
     */
50
    private string $dkimSelector = '';
51
52
    /**
53
     * @ORM\Column(type="text", name="dkim_private_key")
54
     */
55
    private string $dkimPrivateKey = '';
56
57
    /**
58
     * @ORM\OneToMany(targetEntity="User", mappedBy="domain", cascade={"persist", "remove"}, orphanRemoval=true)
59
     * @Assert\Valid()
60
     */
61
    private Collection $users;
62
63
    /**
64
     * @ORM\OneToMany(targetEntity="Alias", mappedBy="domain", cascade={"persist", "remove"}, orphanRemoval=true)
65
     * @Assert\Valid()
66
     */
67
    private Collection $aliases;
68
69
    public function __construct()
70
    {
71
        $this->users = new ArrayCollection();
72
        $this->aliases = new ArrayCollection();
73
    }
74
75
    public function __toString(): string
76
    {
77
        return $this->name;
78
    }
79
80
    public function getId(): ?int
81
    {
82
        return $this->id;
83
    }
84
85
    public function getName(): string
86
    {
87
        return $this->name;
88
    }
89
90
    public function setName(string $name): void
91
    {
92
        $this->name = $name;
93
    }
94
95
    public function getDkimEnabled(): bool
96
    {
97
        return $this->dkimEnabled;
98
    }
99
100
    public function setDkimEnabled(bool $dkimEnabled): void
101
    {
102
        $this->dkimEnabled = $dkimEnabled;
103
    }
104
105
    public function getDkimSelector(): string
106
    {
107
        return $this->dkimSelector;
108
    }
109
110
    public function setDkimSelector(string $dkimSelector): void
111
    {
112
        $this->dkimSelector = $dkimSelector;
113
    }
114
115
    public function getDkimPrivateKey(): string
116
    {
117
        return $this->dkimPrivateKey;
118
    }
119
120
    public function setDkimPrivateKey(string $dkimPrivateKey): void
121
    {
122
        $this->dkimPrivateKey = $dkimPrivateKey;
123
    }
124
125
    public function getUsers(): iterable
126
    {
127
        return $this->users;
128
    }
129
130
    public function getAliases(): iterable
131
    {
132
        return $this->aliases;
133
    }
134
}
135