Completed
Push — master ( 7c8768...743de6 )
by Michael
02:24
created

AnalyticsServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
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 26
loc 26
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 4 4 1
A getAnalyticsService() 4 4 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\DI\Container;
12
use Joomla\DI\ServiceProviderInterface;
13
use TheIconic\Tracking\GoogleAnalytics\Analytics;
14
15
/**
16
 * Analytics service provider
17
 */
18 View Code Duplication
class AnalyticsServiceProvider 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...
19
{
20
	/**
21
	 * Registers the service provider with a DI container.
22
	 *
23
	 * @param   Container  $container  The DI container.
24
	 *
25
	 * @return  void
26
	 */
27 12
	public function register(Container $container): void
28
	{
29 12
		$container->share(Analytics::class, [$this, 'getAnalyticsService']);
30 12
	}
31
32
	/**
33
	 * Get the Analytics class service
34
	 *
35
	 * @param   Container  $container  The DI container.
36
	 *
37
	 * @return  Analytics
38
	 */
39 10
	public function getAnalyticsService(Container $container): Analytics
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
	{
41 10
		return new Analytics(true);
42
	}
43
}
44