Passed
Push — master ( ecb34d...b8eee1 )
by Maxence
02:13
created

PersonalSection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
dl 44
loc 44
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getID() 2 2 1
A __construct() 4 4 1
A getName() 2 2 1
A getPriority() 2 2 1
A getIcon() 2 2 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
 * CMS Pico - Integration of Pico within your files to create websites.
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2017
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
namespace OCA\CMSPico\Settings;
28
29
use OCA\CMSPico\AppInfo\Application;
30
use OCP\IL10N;
31
use OCP\IURLGenerator;
32
use OCP\Settings\IIconSection;
0 ignored issues
show
Bug introduced by
The type OCP\Settings\IIconSection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
34 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...
35
36
	/** @var IL10N */
37
	private $l10n;
38
39
	/** @var IURLGenerator */
40
	private $urlGenerator;
41
42
	/**
43
	 * @param IL10N $l10n
44
	 * @param IURLGenerator $urlGenerator
45
	 */
46
	public function __construct(IL10N $l10n,
47
								IURLGenerator $urlGenerator) {
48
		$this->l10n = $l10n;
49
		$this->urlGenerator = $urlGenerator;
50
	}
51
52
	/**
53
	 * {@inheritdoc}
54
	 */
55
	public function getID() {
56
		return Application::APP_NAME;
57
	}
58
59
	/**
60
	 * {@inheritdoc}
61
	 */
62
	public function getName() {
63
		return $this->l10n->t('Pico CMS');
64
	}
65
66
	/**
67
	 * {@inheritdoc}
68
	 */
69
	public function getPriority() {
70
		return 75;
71
	}
72
73
	/**
74
	 * {@inheritdoc}
75
	 */
76
	public function getIcon() {
77
		return $this->urlGenerator->imagePath(Application::APP_NAME, 'pico_cms.svg');
78
	}
79
}
80