Completed
Push — master ( 51a51b...3888f6 )
by Michael
06:55
created

GitHubServiceProvider::getGithubService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Stats\Providers;
4
5
use Joomla\DI\Container;
6
use Joomla\DI\ServiceProviderInterface;
7
use Joomla\Github\Github as BaseGithub;
8
use Stats\GitHub\GitHub;
9
10
/**
11
 * GitHub service provider
12
 *
13
 * @since  1.0
14
 */
15
class GitHubServiceProvider implements ServiceProviderInterface
16
{
17
	/**
18
	 * Registers the service provider with a DI container.
19
	 *
20
	 * @param   Container  $container  The DI container.
21
	 *
22
	 * @return  void
23
	 *
24
	 * @since   1.0
25
	 */
26 1
	public function register(Container $container)
27
	{
28 1
		$container->alias('github', BaseGithub::class)
29 1
			->alias(GitHub::class, BaseGithub::class)
30 1
			->share(BaseGithub::class, [$this, 'getGithubService'], true);
31 1
	}
32
33
	/**
34
	 * Get the `github` service
35
	 *
36
	 * @param   Container  $container  The DI container.
37
	 *
38
	 * @return  GitHub
39
	 *
40
	 * @since   1.0
41
	 */
42 1
	public function getGithubService(Container $container)
43
	{
44
		/** @var \Joomla\Registry\Registry $config */
45 1
		$config = $container->get('config');
46
47 1
		return new GitHub($config->extract('github'));
48
	}
49
}
50