Completed
Push — master ( dc4ad7...0cb618 )
by Emlyn
05:13 queued 03:11
created

ApplicationServicesProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 54
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 1
A constructComponentManager() 0 4 1
A constructRequest() 0 5 1
A constructResponse() 0 5 1
1
<?php
2
/**
3
 * @package    Fuel\Foundation
4
 * @version    2.0
5
 * @author     Fuel Development Team
6
 * @license    MIT License
7
 * @copyright  2010 - 2016 Fuel Development Team
8
 * @link       http://fuelphp.com
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fuel\Foundation;
14
15
use Fuel\Foundation\Request\RequestInterface;
16
use Fuel\Foundation\Response\ResponseInterface;
17
use League\Container\ServiceProvider;
18
19
class ApplicationServicesProvider extends ServiceProvider
20
{
21
22
	protected $provides = [
23
		'fuel.application.event',
24
25
		'fuel.application.request',
26
		'Fuel\Foundation\Request\Cli',
27
28
		'fuel.application.response',
29
		'Fuel\Foundation\Response\Cli',
30
31
		'fuel.application.component_manager',
32
	];
33
34
	/**
35
	 * {@inheritdoc}
36
	 */
37 6
	public function register()
38
	{
39 6
		$this->getContainer()->add('fuel.application.event', 'League\Event\Emitter', true);
40
41 6
		$this->getContainer()->add('Fuel\Foundation\Request\Cli', 'Fuel\Foundation\Request\Cli', false);
42 6
		$this->getContainer()->add('fuel.application.request', $this->constructRequest(), true);
43
44 6
		$this->getContainer()->add('Fuel\Foundation\Response\Cli', 'Fuel\Foundation\Response\Cli', false);
45 6
		$this->getContainer()->add('fuel.application.response', $this->constructResponse(), true);
46
47 6
		$this->getContainer()->add('fuel.application.component_manager', $this->constructComponentManager(), true);
48 6
	}
49
50 6
	protected function constructComponentManager()
51
	{
52 6
		return new ComponentManager($this->getContainer()->get('fuel.config'));
53
	}
54
55
	/**
56
	 * @return RequestInterface
57
	 */
58 6
	protected function constructRequest() : RequestInterface
59
	{
60
		// TODO: perform an actual check to see what kind of request we are dealing with!
61 6
		return $this->getContainer()->get('Fuel\Foundation\Request\Cli');
62
	}
63
64
	/**
65
	 * @return ResponseInterface
66
	 */
67 6
	protected function constructResponse() : ResponseInterface
68
	{
69
		// TODO: perform an actual check to see what kind of request we are dealing with!
70 6
		return $this->getContainer()->get('Fuel\Foundation\Response\Cli');
71
	}
72
}
73