Completed
Push — mysql_improvements ( 2e95ce...dedbef )
by Michael
03:52
created

GitHubServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A getGithubService() 0 7 1
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\{
12
	Container, ServiceProviderInterface
13
};
14
use Joomla\Github\Github as BaseGithub;
15
use Joomla\StatsServer\GitHub\GitHub;
16
17
/**
18
 * GitHub service provider
19
 */
20
class GitHubServiceProvider implements ServiceProviderInterface
21
{
22
	/**
23
	 * Registers the service provider with a DI container.
24
	 *
25
	 * @param   Container  $container  The DI container.
26
	 *
27
	 * @return  void
28
	 */
29 1
	public function register(Container $container)
30
	{
31 1
		$container->alias('github', BaseGithub::class)
32 1
			->alias(GitHub::class, BaseGithub::class)
33 1
			->share(BaseGithub::class, [$this, 'getGithubService'], true);
34 1
	}
35
36
	/**
37
	 * Get the `github` service
38
	 *
39
	 * @param   Container  $container  The DI container.
40
	 *
41
	 * @return  GitHub
42
	 */
43 1
	public function getGithubService(Container $container) : GitHub
44
	{
45
		/** @var \Joomla\Registry\Registry $config */
46 1
		$config = $container->get('config');
47
48 1
		return new GitHub($config->extract('github'));
49
	}
50
}
51