PersonalSection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 0
dl 51
loc 51
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getIcon() 3 3 1
A getID() 3 3 1
A getName() 3 3 1
A getPriority() 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
 * Nextcloud - namespace OCA\Nextnote
4
 *
5
 * @copyright Copyright (c) 2016, Sander Brand ([email protected])
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
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
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\NextNote\Settings;
24
25
26
use OCP\IL10N;
27
use OCP\IURLGenerator;
28
use OCP\Settings\IIconSection;
29
30 View Code Duplication
class PersonalSection implements IIconSection {
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...
31
	/** @var IURLGenerator */
32
	private $urlGenerator;
33
	/** @var IL10N */
34
	private $l;
35
	public function __construct(IURLGenerator $urlGenerator, IL10N $l) {
36
		$this->urlGenerator = $urlGenerator;
37
		$this->l = $l;
38
	}
39
	/**
40
	 * returns the relative path to an 16*16 icon describing the section.
41
	 * e.g. '/core/img/places/files.svg'
42
	 *
43
	 * @returns string
44
	 * @since 13.0.0
45
	 */
46
	public function getIcon() {
47
		return $this->urlGenerator->imagePath('nextnote', 'app-icon.svg');
48
	}
49
	/**
50
	 * returns the ID of the section. It is supposed to be a lower case string,
51
	 * e.g. 'ldap'
52
	 *
53
	 * @returns string
54
	 * @since 9.1
55
	 */
56
	public function getID() {
57
		return 'nextnote';
58
	}
59
	/**
60
	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
61
	 * integration'. Use the L10N service to translate it.
62
	 *
63
	 * @return string
64
	 * @since 9.1
65
	 */
66
	public function getName() {
67
		return $this->l->t('NextNote');
68
	}
69
	/**
70
	 * @return int whether the form should be rather on the top or bottom of
71
	 * the settings navigation. The sections are arranged in ascending order of
72
	 * the priority values. It is required to return a value between 0 and 99.
73
	 *
74
	 * E.g.: 70
75
	 * @since 9.1
76
	 */
77
	public function getPriority() {
78
		return 0;
79
	}
80
}