Completed
Push — master ( 1b2525...eaa10a )
by Albert
11:28
created

HttpServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
1
<?php
2
3
namespace Albert221\Blog\ServiceProvider;
4
5
use League\Container\ServiceProvider\AbstractServiceProvider;
6
use Zend\Diactoros\Response;
7
use Zend\Diactoros\Response\SapiEmitter;
8
use Zend\Diactoros\ServerRequestFactory;
9
10
class HttpServiceProvider extends AbstractServiceProvider
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected $provides = [
16
        'request',
17
        'response',
18
        'emitter',
19
        'route'
20
    ];
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function register()
26
    {
27
        $this->getContainer()->share('request', function () {
28
            return ServerRequestFactory::fromGlobals();
29
        });
30
31
        $this->getContainer()->share('response', Response::class);
32
33
        $this->getContainer()->share('emitter', SapiEmitter::class);
34
35
        $this->getContainer()->share('route', function () {
36
            return require $this->getContainer()
37
                ->get('baseDir').'/config/routes.php';
38
        });
39
    }
40
}