Passed
Push — master ( c222ba...946430 )
by John
15:06 queued 11s
created

SettingsManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 12
dl 0
loc 43
rs 10
c 1
b 1
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A replyToInitiator() 0 3 1
A sendPasswordByMail() 0 3 1
A __construct() 0 2 1
A enforcePasswordProtection() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2017 Bjoern Schiessle <[email protected]>
7
 *
8
 * @author Bjoern Schiessle <[email protected]>
9
 * @author Roeland Jago Douma <[email protected]>
10
 *
11
 * @license GNU AGPL version 3 or any later version
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 */
27
28
namespace OCA\ShareByMail\Settings;
29
30
use OCP\IConfig;
31
32
class SettingsManager {
33
34
	/** @var IConfig */
35
	private $config;
36
37
	private $sendPasswordByMailDefault = 'yes';
38
39
	private $enforcePasswordProtectionDefault = 'no';
40
41
	private $replyToInitiatorDefault = 'yes';
42
43
	public function __construct(IConfig $config) {
44
		$this->config = $config;
45
	}
46
47
	/**
48
	 * should the password for a mail share be send to the recipient
49
	 *
50
	 * @return bool
51
	 */
52
	public function sendPasswordByMail(): bool {
53
		$sendPasswordByMail = $this->config->getAppValue('sharebymail', 'sendpasswordmail', $this->sendPasswordByMailDefault);
54
		return $sendPasswordByMail === 'yes';
55
	}
56
57
	/**
58
	 * do we require a share by mail to be password protected
59
	 *
60
	 * @return bool
61
	 */
62
	public function enforcePasswordProtection(): bool {
63
		$enforcePassword = $this->config->getAppValue('sharebymail', 'enforcePasswordProtection', $this->enforcePasswordProtectionDefault);
64
		return $enforcePassword === 'yes';
65
	}
66
67
	/**
68
	 * should add reply to with initiator mail
69
	 *
70
	 * @return bool
71
	 */
72
	public function replyToInitiator(): bool {
73
		$replyToInitiator =  $this->config->getAppValue('sharebymail', 'replyToInitiator', $this->replyToInitiatorDefault);
74
		return $replyToInitiator === 'yes';
75
	}
76
}
77