Completed
Push — master ( 67c38d...036b27 )
by Chris
02:43
created

ClassLoaderService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
1
<?php
2
namespace Darya\Foundation\Providers;
3
4
use Darya\Common\Autoloader;
5
use Darya\Service\Contracts\Container;
6
use Darya\Service\Contracts\Provider;
7
8
/**
9
 * A service provider that provides an autoloader for application classes.
10
 * 
11
 * @author Chris Andrew <[email protected]>
12
 */
13
class ClassLoaderService implements Provider
14
{
15
	/**
16
	 * Register an autoloader for application classes.
17
	 * 
18
	 * @param Container $container
19
	 */
20
	public function register(Container $container)
21
	{
22
		$configuration = $container->resolve('Darya\Foundation\Configuration');
23
		
24
		$basePath = $container->get('path');
25
		$namespace = $configuration->get('project.namespace', 'Application');
26
		
27
		// Map the configured namespace to the application directory
28
		$autoloader = new Autoloader($basePath, array(
29
			$namespace => 'application'
30
		));
31
		
32
		$autoloader->register();
33
		
34
		$container->register(array(
35
			'Darya\Common\Autoloader' => $autoloader
36
		));
37
	}
38
}
39