Completed
Push — master ( 1c02a4...0f40a4 )
by Rafał
06:14
created

Tenant::setDomainName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Component.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\MultiTenancy\Model;
16
17
use SWP\Component\Common\Model\EnableableTrait;
18
use SWP\Component\Common\Model\SoftDeletableTrait;
19
use SWP\Component\Common\Model\TimestampableTrait;
20
21
class Tenant implements TenantInterface
22
{
23
    use SoftDeletableTrait, TimestampableTrait, EnableableTrait;
24
25
    /**
26
     * @var mixed
27
     */
28
    protected $id;
29
30
    /**
31
     * @var string
32
     */
33
    protected $subdomain;
34
35
    /**
36
     * @var string
37
     */
38
    protected $domainName;
39
40
    /**
41
     * @var string
42
     */
43
    protected $name;
44
45
    /**
46
     * @var string
47
     */
48
    protected $code;
49
50
    /**
51
     * @var OrganizationInterface
52
     */
53
    protected $organization;
54
55
    /**
56
     * Tenant constructor.
57
     */
58
    public function __construct()
59
    {
60
        $this->createdAt = new \DateTime();
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function setId($id)
75
    {
76
        $this->id = $id;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getSubdomain()
83
    {
84
        return $this->subdomain;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function setSubdomain($subdomain)
91
    {
92
        $this->subdomain = $subdomain;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function getName()
99
    {
100
        return $this->name;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function setName($name)
107
    {
108
        $this->name = $name;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function getCode()
115
    {
116
        return $this->code;
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122
    public function setCode($code)
123
    {
124
        if (null !== $this->code) {
125
            throw new \LogicException('Tenant\'s code is already set. Can not change it.');
126
        }
127
128
        $this->code = $code;
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134
    public function setOrganization(OrganizationInterface $organization)
135
    {
136
        $this->organization = $organization;
137
    }
138
139
    /**
140
     * {@inheritdoc}
141
     */
142
    public function getOrganization()
143
    {
144
        return $this->organization;
145
    }
146
147
    /**
148
     * {@inheritdoc}
149
     */
150
    public function getDomainName()
151
    {
152
        return $this->domainName;
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158
    public function setDomainName($domainName)
159
    {
160
        $this->domainName = $domainName;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function __toString()
167
    {
168
        return (string) $this->subdomain;
169
    }
170
}
171