Completed
Push — master ( 10f95b...bf15d4 )
by Michael
09:02
created

GitHubServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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
 * @since  1.0
21
 */
22
class GitHubServiceProvider implements ServiceProviderInterface
23
{
24
	/**
25
	 * Registers the service provider with a DI container.
26
	 *
27
	 * @param   Container  $container  The DI container.
28
	 *
29
	 * @return  void
30
	 *
31
	 * @since   1.0
32
	 */
33 1
	public function register(Container $container)
34
	{
35 1
		$container->alias('github', BaseGithub::class)
36 1
			->alias(GitHub::class, BaseGithub::class)
37 1
			->share(BaseGithub::class, [$this, 'getGithubService'], true);
38 1
	}
39
40
	/**
41
	 * Get the `github` service
42
	 *
43
	 * @param   Container  $container  The DI container.
44
	 *
45
	 * @return  GitHub
46
	 *
47
	 * @since   1.0
48
	 */
49 1
	public function getGithubService(Container $container) : GitHub
50
	{
51
		/** @var \Joomla\Registry\Registry $config */
52 1
		$config = $container->get('config');
53
54 1
		return new GitHub($config->extract('github'));
55
	}
56
}
57