Completed
Push — master ( 3d08a4...4b8715 )
by Roeland
10s
created

ItemFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 21.15 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 11
loc 52
ccs 0
cts 21
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A newItem() 0 10 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) 2018 Roeland Jago Douma <[email protected]>
4
 *
5
 * @author Roeland Jago Douma <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Files_Antivirus;
25
26
use OCA\Files_Antivirus\Db\ItemMapper;
27
use OCP\Activity\IManager as ActivityManager;
28
use OCP\Files\File;
29
use OCP\IL10N;
30
use OCP\ILogger;
31
32
class ItemFactory {
33
	/** @var IL10N */
34
	private $l10n;
35
36
	/** @var AppConfig */
37
	private $config;
38
39
	/** @var ActivityManager */
40
	private $activityManager;
41
42
	/** @var ItemMapper */
43
	private $itemMapper;
44
45
	/** @var ILogger */
46
	private $logger;
47
48
	/**
49
	 * ItemFactory constructor.
50
	 *
51
	 * @param IL10N $l10n
52
	 * @param AppConfig $appConfig
53
	 * @param ActivityManager $activityManager
54
	 * @param ItemMapper $itemMapper
55
	 * @param ILogger $logger
56
	 */
57 View Code Duplication
	public function __construct(IL10N $l10n,
0 ignored issues
show
Duplication introduced by
This method 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...
58
								AppConfig $appConfig,
59
								ActivityManager $activityManager,
60
								ItemMapper $itemMapper,
61
								ILogger $logger) {
62
		$this->l10n = $l10n;
63
		$this->config = $appConfig;
64
		$this->activityManager = $activityManager;
65
		$this->itemMapper = $itemMapper;
66
		$this->logger = $logger;
67
	}
68
69
	/**
70
	 * @param File $file
71
	 * @return Item
72
	 */
73
	public function newItem(File $file) {
74
		return new Item(
75
			$this->l10n,
76
			$this->config,
77
			$this->activityManager,
78
			$this->itemMapper,
79
			$this->logger,
80
			$file
81
		);
82
	}
83
}
84