Completed
Push — master ( 77abb4...5b1cd3 )
by Chris
02:37
created

HttpService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 1
1
<?php
2
namespace Darya\Foundation\Providers;
3
4
use Darya\Http\Request;
5
use Darya\Http\Response;
6
use Darya\Http\Session;
7
use Darya\Service\Contracts\Container;
8
use Darya\Service\Contracts\Provider;
9
10
/**
11
 * A service provider that provides HTTP request and response objects.
12
 * 
13
 * Also provides the default PHP session.
14
 * 
15
 * @author Chris Andrew <[email protected]>
16
 */
17
class HttpService implements Provider
18
{
19
	/**
20
	 * Register a global HTTP request, response and session with the container.
21
	 * 
22
	 * @param Container $container
23
	 */
24
	public function register(Container $container)
25
	{
26
		$container->register(array(
27
			'Darya\Http\Request' => function ($container) {
28
				return Request::createFromGlobals($container->resolve('Darya\Http\Session'));
29
			},
30
			'Darya\Http\Response' => new Response,
31
			'Darya\Http\Session' => new Session\Php
32
		));
33
	}
34
}
35