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

GitHubServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 31
ccs 5
cts 8
cp 0.625
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\Container;
12
use Joomla\DI\ServiceProviderInterface;
13
use Joomla\Github\Github as BaseGithub;
14
use Joomla\StatsServer\GitHub\GitHub;
15
16
/**
17
 * GitHub service provider
18
 */
19
class GitHubServiceProvider implements ServiceProviderInterface
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->alias('github', BaseGithub::class)
31 11
			->alias(GitHub::class, BaseGithub::class)
32 11
			->share(BaseGithub::class, [$this, 'getGithubService']);
33 11
	}
34
35
	/**
36
	 * Get the `github` service
37
	 *
38
	 * @param   Container  $container  The DI container.
39
	 *
40
	 * @return  GitHub
41
	 */
42
	public function getGithubService(Container $container): GitHub
43
	{
44
		/** @var \Joomla\Registry\Registry $config */
45
		$config = $container->get('config');
46
47
		return new GitHub($config->extract('github'));
48
	}
49
}
50