Completed
Push — master ( 9a3a3c...24148b )
by Michael
14s
created

RepositoryServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 4 4 1
A getStatisticsRepositoryService() 6 6 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
 * Joomla! Statistics Server
4
 *
5
 * @copyright  Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
6
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
7
 */
8
9
namespace Joomla\StatsServer\Providers;
10
11
use Joomla\Database\DatabaseInterface;
12
use Joomla\DI\Container;
13
use Joomla\DI\ServiceProviderInterface;
14
use Joomla\StatsServer\Repositories\StatisticsRepository;
15
16
/**
17
 * Repository service provider
18
 */
19 View Code Duplication
class RepositoryServiceProvider implements ServiceProviderInterface
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...
20
{
21
	/**
22
	 * Registers the service provider with a DI container.
23
	 *
24
	 * @param   Container  $container  The DI container.
25
	 *
26
	 * @return  void
27
	 */
28 11
	public function register(Container $container): void
29
	{
30 11
		$container->share(StatisticsRepository::class, [$this, 'getStatisticsRepositoryService']);
31 11
	}
32
33
	/**
34
	 * Get the StatisticsRepository service
35
	 *
36
	 * @param   Container  $container  The DI container.
37
	 *
38
	 * @return  StatisticsRepository
39
	 */
40 7
	public function getStatisticsRepositoryService(Container $container): StatisticsRepository
41
	{
42 7
		return new StatisticsRepository(
43 7
			$container->get(DatabaseInterface::class)
44
		);
45
	}
46
}
47