Completed
Push — master ( f90f4d...a79447 )
by Lukas
37:29 queued 19:54
created

Capabilities   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCapabilities() 0 7 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Roeland Jago Douma <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
namespace OC\Security\Bruteforce;
22
23
use OCP\Capabilities\IPublicCapability;
24
use OCP\IRequest;
25
26
class Capabilities implements IPublicCapability {
27
	/** @var IRequest */
28
	private $request;
29
30
	/** @var Throttler */
31
	private $throttler;
32
33
	/**
34
	 * Capabilities constructor.
35
	 *
36
	 * @param IRequest $request
37
	 * @param Throttler $throttler
38
	 */
39
	public function __construct(IRequest $request,
40
								Throttler $throttler) {
41
		$this->request = $request;
42
		$this->throttler = $throttler;
43
	}
44
45
	public function getCapabilities() {
46
		return [
47
			'bruteforce' => [
48
				'delay' => $this->throttler->getDelay($this->request->getRemoteAddress())
49
			]
50
		];
51
	}
52
}
53