ByFilter   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getIdentifier() 3 3 1
A getName() 3 3 1
A getPriority() 3 3 1
A getIcon() 3 3 1
A filterTypes() 3 3 1
A allowedApps() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Joas Schilling <[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
22
namespace OCA\Activity\Filter;
23
24
25
use OCP\Activity\IFilter;
26
use OCP\IL10N;
27
use OCP\IURLGenerator;
28
29 View Code Duplication
class ByFilter implements IFilter {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
31
	/** @var IL10N */
32
	protected $l;
33
34
	/** @var IURLGenerator */
35
	protected $url;
36
37
	/**
38
	 * @param IL10N $l
39
	 * @param IURLGenerator $url
40
	 */
41
	public function __construct(IL10N $l, IURLGenerator $url) {
42
		$this->l = $l;
43
		$this->url = $url;
44
	}
45
46
	/**
47
	 * @return string Lowercase a-z only identifier
48
	 * @since 9.2.0
49
	 */
50
	public function getIdentifier() {
51
		return 'by';
52
	}
53
54
	/**
55
	 * @return string A translated string
56
	 * @since 9.2.0
57
	 */
58
	public function getName() {
59
		return $this->l->t('By others');
60
	}
61
62
	/**
63
	 * @return int
64
	 * @since 9.2.0
65
	 */
66
	public function getPriority() {
67
		return 2;
68
	}
69
70
	/**
71
	 * @return string Full URL to an icon, empty string when none is given
72
	 * @since 9.2.0
73
	 */
74
	public function getIcon() {
75
		return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/contacts.svg'));
76
	}
77
78
	/**
79
	 * @param string[] $types
80
	 * @return string[] An array of allowed apps from which activities should be displayed
81
	 * @since 9.2.0
82
	 */
83
	public function filterTypes(array $types) {
84
		return $types;
85
	}
86
87
	/**
88
	 * @return string[] An array of allowed apps from which activities should be displayed
89
	 * @since 9.2.0
90
	 */
91
	public function allowedApps() {
92
		return [];
93
	}
94
}
95