Test Failed
Push — master ( 4abc3b...a9eb80 )
by Julien
04:29
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 11
c 2
b 1
f 0
dl 0
loc 28
ccs 0
cts 10
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 3
1
<?php
2
/**
3
 * This file is part of the Zemit Framework.
4
 *
5
 * (c) Zemit Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.txt
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Zemit\Provider\Response;
12
13
use Phalcon\Di\DiInterface;
14
use Phalcon\Http\Response;
15
use Zemit\Provider\AbstractServiceProvider;
16
17
/**
18
 * Class ServiceProvider
19
 *
20
 * @author Julien Turbide <[email protected]>
21
 * @copyright Zemit Team <[email protected]>
22
 *
23
 * @since 1.0
24
 * @version 1.0
25
 *
26
 * @package Zemit\Provider\Response
27
 */
28
class ServiceProvider extends AbstractServiceProvider
29
{
30
    /**
31
     * The Service name.
32
     * @var string
33
     */
34
    protected $serviceName = 'response';
35
    
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @return void
40
     */
41
    public function register(DiInterface $di): void
42
    {
43
        $di->setShared($this->getName(), function() use ($di) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
44
            $response = new Response();
45
            $response->setDI($di);
46
            
47
            $config = $di->get('config');
48
            $headers = $config->path('response.headers', []);
49
            if (!empty($headers)) {
50
                foreach ($headers as $name => $value) {
51
                    $response->setHeader($name, $value);
52
                }
53
            }
54
            
55
            return $response;
56
        });
57
    }
58
}
59