Completed
Pull Request — master (#582)
by
unknown
239:17 queued 237:52
created

GroupFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A format() 0 5 1
1
<?php
2
/**
3
 * @author Joas Schilling <[email protected]>
4
 * @author Sujith Haridasan <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2016, ownCloud, Inc.
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Activity\Formatter;
24
25
use OC\Group\Manager;
26
use OCP\Activity\IEvent;
27
use OCP\Util;
28
29
class GroupFormatter implements IFormatter {
30
31
	protected $groupManager;
32 3
	public function __construct(Manager $groupManager) {
33 3
		$this->groupManager = $groupManager;
34 3
	}
35
36
	/**
37
	 * @param IEvent $event
38
	 * @param string $parameter The parameter to be formatted
39
	 * @return string The formatted parameter
40
	 */
41 2
	public function format(IEvent $event, $parameter) {
42 2
		$group = $this->groupManager->get($parameter);
43 2
		$displayName = $group->getDisplayName();
44 2
		return '<parameter>' . Util::sanitizeHTML($displayName) . '</parameter>';
45
	}
46
}
47