Completed
Pull Request — master (#1616)
by
unknown
08:27
created

MailAccount   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 93.1%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 16
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 90
ccs 54
cts 58
cp 0.931
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
F __construct() 0 44 14
A toJson() 0 21 2
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 * @author Jan-Christoph Borchardt <[email protected]>
6
 * @author Lukas Reschke <[email protected]>
7
 * @author Thomas Müller <[email protected]>
8
 *
9
 * Mail
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License, version 3,
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
25
namespace OCA\Mail\Db;
26
27
use OCP\AppFramework\Db\Entity;
28
29
/**
30
 * Class MailAccount
31
 *
32
 * @package OCA\Mail\Db
33
 *
34
 * @method string getUserId()
35
 * @method void setUserId(string $userId)
36
 * @method string getName()
37
 * @method void setName(string $name)
38
 * @method string getEmail()
39
 * @method void setEmail(string $email)
40
 * @method string getInboundHost()
41
 * @method void setInboundHost(string $inboundHost)
42
 * @method integer getInboundPort()
43
 * @method void setInboundPort(integer $inboundPort)
44
 * @method string getInboundSslMode()
45
 * @method void setInboundSslMode(string $inboundSslMode)
46
 * @method string getInboundUser()
47
 * @method void setInboundUser(string $inboundUser)
48
 * @method string getInboundPassword()
49
 * @method void setInboundPassword(string $inboundPassword)
50
 * @method string getOutboundHost()
51
 * @method void setOutboundHost(string $outboundHost)
52
 * @method integer getOutboundPort()
53
 * @method void setOutboundPort(integer $outboundPort)
54
 * @method string getOutboundSslMode()
55
 * @method void setOutboundSslMode(string $outboundSslMode)
56
 * @method string getOutboundUser()
57
 * @method void setOutboundUser(string $outboundUser)
58
 * @method string getOutboundPassword()
59
 * @method void setOutboundPassword(string $outboundPassword)
60
 * @method void setSignature(string $signature)
61
 * @method string getSignature()
62
 */
63
class MailAccount extends Entity {
64
65
	public $userId;
66
	public $name;
67
	public $email;
68
	public $inboundHost;
69
	public $inboundPort;
70
	public $inboundSslMode;
71
	public $inboundUser;
72
	public $inboundPassword;
73
	public $outboundHost;
74
	public $outboundPort;
75
	public $outboundSslMode;
76
	public $outboundUser;
77
	public $outboundPassword;
78
	public $signature;
79
80
	/**
81
	 * @param array $params
82
	 */
83 5
	public function __construct(array $params=[]) {
84
85 5
		if (isset($params['accountId'])) {
86 1
			$this->setId($params['accountId']);
87 1
		}
88 5
		if (isset($params['accountName'])) {
89 1
			$this->setName($params['accountName']);
90 1
		}
91 5
		if (isset($params['emailAddress'])) {
92 1
			$this->setEmail($params['emailAddress']);
93 1
		}
94
95 5
		if (isset($params['imapHost'])) {
96 1
			$this->setInboundHost($params['imapHost']);
97 1
		}
98 5
		if (isset($params['imapPort'])) {
99 1
			$this->setInboundPort($params['imapPort']);
100 1
		}
101 5
		if (isset($params['imapSslMode'])) {
102 1
			$this->setInboundSslMode($params['imapSslMode']);
103 1
		}
104 5
		if (isset($params['imapUser'])) {
105 1
			$this->setInboundUser($params['imapUser']);
106 1
		}
107 5
		if (isset($params['imapPassword'])) {
108
			$this->setInboundPassword($params['imapPassword']);
109
		}
110
111 5
		if (isset($params['smtpHost'])) {
112 1
			$this->setOutboundHost($params['smtpHost']);
113 1
		}
114 5
		if (isset($params['smtpPort'])) {
115 1
			$this->setOutboundPort($params['smtpPort']);
116 1
		}
117 5
		if (isset($params['smtpSslMode'])) {
118 1
			$this->setOutboundSslMode($params['smtpSslMode']);
119 1
		}
120 5
		if (isset($params['smtpUser'])) {
121 1
			$this->setOutboundUser($params['smtpUser']);
122 1
		}
123 5
		if (isset($params['smtpPassword'])) {
124
			$this->setOutboundPassword($params['smtpPassword']);
125
		}
126 5
	}
127
128
	/**
129
	 * @return array
130
	 */
131 2
	public function toJson() {
132
		$result = [
133 2
			'accountId' => $this->getId(),
134 2
			'name' => $this->getName(),
135 2
			'emailAddress' => $this->getEmail(),
136 2
			'imapHost' => $this->getInboundHost(),
137 2
			'imapPort' => $this->getInboundPort(),
138 2
			'imapUser' => $this->getInboundUser(),
139 2
			'imapSslMode' => $this->getInboundSslMode(),
140 2
			'signature' => $this->getSignature()
141 2
		];
142
143 2
		if (!is_null($this->getOutboundHost())) {
144 2
			$result['smtpHost'] = $this->getOutboundHost();
145 2
			$result['smtpPort'] = $this->getOutboundPort();
146 2
			$result['smtpUser'] = $this->getOutboundUser();
147 2
			$result['smtpSslMode'] = $this->getOutboundSslMode();
148 2
		}
149
150 2
		return $result;
151
	}
152
}
153